I read the line NetworkStreamfor jsonand then deserialize using Newtonsoft.Json.
Sometimes two objects jsoncan be sent back and read at the same time in the stream. But Newtonsoft.Json serializergives me only one object.
For example, if I have the following line in a stream:
{"name":"John Doe","age":10}{"name":"Jane Doe","age":10}
If I deserialize a stream, it serializerreads the entire stream, but gives only the first object.
Is there a way to make serializerread only the first object from the stream and then read the next object in the next iteration of the loop?
the code:
public static Person Deserialize(Stream stream)
{
var Serializer = new JsonSerializer();
var streamReader = new StreamReader(stream, new UTF8Encoding());
return Serializer.Deserialize<Person>(new JsonTextReader(streamReader));
}
I cannot desrialize as a list because I am not getting an array json.