Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path

后端 未结 3 1146
天涯浪人
天涯浪人 2020-11-30 08:36

I am working on a Windows Phone 8.1 application involving location. I am receiving Json data from my API. My API returns data that looks like:



        
3条回答
  •  佛祖请我去吃肉
    2020-11-30 09:08

    I ran into a very similar problem with my Xamarin Windows Phone 8.1 app. The reason JObject.Parse(json) would not work for me was because my Json had a beginning "[" and an ending "]". In order to make it work, I had to remove those two characters. From your example, it looks like you might have the same issue.

    jsonResult = jsonResult.TrimStart(new char[] { '[' }).TrimEnd(new char[] { ']' });
    

    I was then able to use the JObject.Parse(jsonResult) and everything worked.

提交回复
热议问题