Use JSON.NET to parse JSON object stream
Use JSON.NET to deserialize a delimiter-free continuous stream of JSON objects into IEnumerable<T>
as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Usage:
The following example demonstrates iterating IEnumerable<T>
while a stream is open:
1 2 3 4 5 6 7 8 9 |
|
Other notes:
IEnumerable<T>
while the stream is open. CheckAdditionalContent
to false
to prevent exceptions when extra content is encountered after deserialization. Example:
Please refer to the following example on the JSON.NET website: "Read multiple fragments using JsonReader" (https://www.php.cn/link/b0a3f2a0d6f86051e6ab6c49d6d99e75).
The above is the detailed content of How to Parse a Stream of Concatenated JSON Objects with JSON.NET?. For more information, please follow other related articles on the PHP Chinese website!