A
A
aiexz2018-11-21 23:23:59
API
aiexz, 2018-11-21 23:23:59

Why is there an error when parsing JSON?

When parsing such a response from the server

{"response":{"short_url":"https:\/\/vk.cc\/8CcI9Y"}}

An error occurs An exception was thrown: "Newtonsoft.Json.JsonReaderException" in Newtonsoft.Json.dll
When parsing requests that do not contain a link, everything is fine, I use the VK API
Code to decrypt the request
public Dictionary<string, string> URLShorter(string URL)
        {
            HttpRequest URLShorter = new HttpRequest();
            URLShorter.AddUrlParam("url", URL);
            URLShorter.AddUrlParam("access_token", _Token);
            URLShorter.AddUrlParam("version", "5.92");
            string Result = URLShorter.Get(__VKAPIURL + "utils.checkLink").ToString();
            Dictionary<string, string> Dist = JsonConvert.DeserializeObject<Dictionary<string, string>>(Result);
            return Dist;
        }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2018-11-21
@aiexz

Everything is fine with json:
The problem is either in Newtonsoft.Json.dll itself or the answer is not the same as you show.

D
Denis Zagaevsky, 2018-11-21
@zagayevskiy

1) there should be a more accurate description of the error
2) mb is neededDictionary<string, Dictionary<string, string>>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question