小编Esp*_*ans的帖子

无法使用 JObject.Parse() 解析 JSON

每次我尝试解析 JSON 时都会遇到此异常:

    Unhandled exception. Newtonsoft.Json.JsonReaderException: Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1, position 1.
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
   at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
   at Newtonsoft.Json.Linq.JObject.Parse(String json)
   at ai.Program.Main(String[] args) in /home/asdf/RiderProjects/ai/ai/Program.cs:line 19
Run Code Online (Sandbox Code Playgroud)

我的一些代码

url2 = "img"; 
var client = new RestClient("example.org?url=" + url2);
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
dynamic epic = JObject.Parse(response.Content);

string stuff = epic.stuff;

Console.WriteLine(stuff);
Run Code Online (Sandbox Code Playgroud)

c# json

-1
推荐指数
1
解决办法
2362
查看次数

标签 统计

c# ×1

json ×1