I am facing one strange problem in JSON array while receiving from a server, I tried to deserialize it but it says
I have created a class and tried to deserialize it into that object but, it says
the class is given below.
class bundle
{
public string msgid { get; set; }
public string messagetype { get; set; }
public string message { get; set; }
public string from { get; set; }
}
Exception: Newtonsoft.Json.JsonReaderException: Additional text encountered after finished reading JSON content: y. Path '', line 1, position 93. at Newtonsoft.Json.JsonTextReader.Read() at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value) at Listener.Program.LogStatus(Boolean receiving, Byte[] buffer, Int32 length) in at Listener.Program.d__5.MoveNext() in --- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Listener.Program.d__1.MoveNext()
and the array which I am getting is below,
{"messagetype":"chatmsg","msgid":"123_119","from":"sam","message":"Hi there, good morning ! "}
{"messagetype":"chatmsg","msgid":"123_120","from":"sam","message":"how are you?"}
{"messagetype":"chatmsg","msgid":"6478316959_121","from":"sam","message":"this is msg"} ood morning !"}
{"messagetype":"ping"}g","msgid":"6478316959_121","from":"sam","message":"you are crazy"} orning ! "}
it is unexpected token at the end.
{"messagetype":"chatmsg","msgid":"6478316959_121","from":"sam","message":"this is msg"} ood morning !"}, it appears somebody tried to overwrite a line in the file, and failed to overwrite it completely. Are you sure your JSON is really that bad? - dbc