R
R
Renat Iliev2014-07-22 10:25:01
JSON
Renat Iliev, 2014-07-22 10:25:01

Where does the server response JSON parsing error come from?

I am writing a server-client application, requests / responses go to JSON (I like to work with it :) ), I use the Newtonsoft.Json library to parse the response, so, for example, the server response:

{
  "status": true,
  "location": "https://ru.wargaming.net/id/openid/?openid.assoc_handle=%7BHMAC-SHA1%7D%7B53c3b656%7D%7BdbdXfQ%3D%3D%7D&openid.ax.if_available=ext0%2Cext1%2Cext2&openid.ax.mode=fetch_request&openid.ax.type.ext0=http%3A%2F%2Faxschema.openid.wargaming.net%2Fspa%2Fid&openid.ax.type.ext1=http%3A%2F%2Faxschema.org%2FnamePerson%2Ffriendly&openid.ax.type.ext2=http%3A%2F%2Faxschema.openid.wargaming.net%2Fidentity%2Fsso%2Fnotifications%2Fdisable&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.ax=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.realm=https%3A%2F%2Fapi.worldoftanks.ru%2F&openid.return_to=https%3A%2F%2Fapi.worldoftanks.ru%2Fid%2Fcomplete%2F%3Fredirect_uri%3Dhttps%253A%252F%252Fapi.worldoftanks.ru%252Fwot%252Fblank%252F%26application_id%3D0775c3d2e437b4d3a2e386036571e297%26expires_at%3D1407221921%26janrain_nonce%3D2014-07-22T06%253A58%253A41ZepFnu1\"}d/openid/?openid.assoc_handle=%7BHMAC-SHA1%7D%7B53c3b656%7D%7BdbdXfQ%3D%3D%7D&openid.ax.if_available=ext0%2Cext1%2Cext2&openid.ax.mode=fetch_request&openid.ax.type.ext0=http%3A%2F%2Faxschema.openid.wargaming.net%2Fspa%2Fid&openid.ax.type.ext1=http%3A%2F%2Faxschema.org%2FnamePerson%2Ffriendly&openid.ax.type.ext2=http%3A%2F%2Faxschema.openid.wargaming.net%2Fidentity%2Fsso%2Fnotifications%2Fdisable&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.ax=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.realm=https%3A%2F%2Fapi.worldoftanks.ru%2F&openid.return_to=https%3A%2F%2Fapi.worldoftanks.ru%2Fid%2Fcomplete%2F%3Fredirect_uri%3Dhttps%253A%252F%252Fapi.worldoftanks.ru%252Fwot%252Fblank%252F%26application_id%3D0775c3d2e437b4d3a2e386036571e297%26expires_at%3D1407221921%26janrain_nonce%3D2014-07-22T06%253A58%253A41ZepFnu1\"}d/openid/?openid.assoc_handle=%7BHMAC-SHA1%7D%7B53c3b656%7D%7BdbdXfQ%3D%3D%7D&openid.ax.if_available=ext0%2Cext1%2Cext2&openid.ax.mode=fetch_request&openid.ax.type.ext0=http%3A%2F%2Faxschema.openid.wargaming.net%2Fspa%2Fid&openid.ax.type.ext1=http%3A%2F%2Faxschema.org%2FnamePerson%2Ffriendly&openid.ax.type.ext2=http%3A%2F%2Faxschema.openid.wargaming.net%2Fidentity%2Fsso%2Fnotifications%2Fdisable&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.ax=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.realm=https%3A%2F%2Fapi.worldoftanks.ru%2F&openid.return_to=https%3A%2F%2Fapi.worldoftanks.ru%2Fid%2Fcomplete%2F%3Fredirect_uri%3Dhttps%253A%252F%252Fapi.worldoftanks.ru%252Fwot%252Fblank%252F%26application_id%3D0775c3d2e437b4d3a2e386036571e297%26expires_at%3D1407221921%2"
}

Reformatted for readability.
So, when parsing with JObject (function JObject.Parse (json)) I get an exception:
Необработанное исключение типа "Newtonsoft.Json.JsonReaderException" произошло в Newtonsoft.Json.dll

Дополнительные сведения: Additional text encountered after finished reading JSON content: \. Path '', line 1, position 1175.

Moreover, this happens in any server responses (the contents of which are very different), only the position and "<some symbol>.Path" change.
What is the problem? I have already processed the string in every possible way both on the server and on the client, to no avail.
And the oddity: The same string (I took it directly from the client with the output before parsing), for example, Notepad ++ with the JSON Viewer plugin, calmly parses.
Ps And yes, on the JSON server the string is collected by the same JObject.
UPD. I dug around with a debugger and found out:
86c44ccec730483988606175bae34b02.png
Where does the "\0" clog up the response from?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2014-07-22
@SashaSkot

5cc80ab23536415ca2722000ec742b41.PNG
Most likely, your parser processes the string crookedly, the picture shows that there are a sequence of characters "} that confuse the parser, it perceives this as the end of a string constant and a block, which is fundamentally wrong.

V
Vyacheslav Zolotov, 2014-07-22
@SZolotov

Have you tried deserializing with JsonConvert?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question