Newtonsoft.Json.JsonReaderException: Additional text encountered after finished reading JSON content: Newtonsoft.Json.JsonReaderException: Additional text encountered after finished reading JSON content: arrays arrays

Newtonsoft.Json.JsonReaderException: Additional text encountered after finished reading JSON content:


After alot of work, I came up with this:

string final = string.Empty;string name = encoder.GetString(buffer);char []arr = name.ToArray();boolean bln = true;foreach (char item in arr){    if (bln)    {        if (item == '}')        {            final += item.ToString();            break;        }        else        {            final += item.ToString();        }    }}Console.WriteLine(final);

which will truncate the rest of the characters.


all of array item keys must placed in your finally class by same name, change your class to this and test it again:

class bundle{    public string msgid { get; set; }    public string messagetype { get; set; }    public string message { get; set; }    public string from { get; set; }}

elso you can convert your JSON array by tools like this: JSON2Csharp


I think your Json is invalid and because you have multiple root element you need to deserialize to List<bundle>.

{"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. Good morning !"}                                                                                                                            {"messagetype":"ping","msgid":"6478316959_121","from":"sam","message":"you are crazy morning ! "}