C# 4.0 JSon.netjobject.Parse

C# 4.0 JSon.netjobject.Parse,c#-4.0,json.net,C# 4.0,Json.net,在下面的代码中,我使用的是Json.net。由于某种原因,我在 JObject o=JObject.Parse(图片) 但对 JObject googleSearch=JObject.Parse(googleSearchText) 谁能告诉我这是为什么吗 string googleSearchText = @"{ ""results"": [ { ""GsearchResultClass"": ""GwebSearch"", ""unescapedUrl"": ""htt

在下面的代码中,我使用的是Json.net。由于某种原因,我在
JObject o=JObject.Parse(图片)
但对
JObject googleSearch=JObject.Parse(googleSearchText)

谁能告诉我这是为什么吗

string googleSearchText = @"{
  ""results"": [
  {
    ""GsearchResultClass"": ""GwebSearch"",
    ""unescapedUrl"": ""http://en.wikipedia.org/wiki/Paris_Hilton"",
    ""url"": ""http://en.wikipedia.org/wiki/Paris_Hilton"",
    ""visibleUrl"": ""en.wikipedia.org"",
    ""cacheUrl"": ""http://www.google.com/search?q=cache:TwrPfhd22hYJ:en.wikipedia.org"",
    ""title"": ""<b>Paris Hilton</b> - Wikipedia, the free encyclopedia"",
    ""titleNoFormatting"": ""Paris Hilton - Wikipedia, the free encyclopedia"",
    ""content"": ""[1] In 2006, she released her debut album...""
  },
  {
    ""GsearchResultClass"": ""GwebSearch"",
    ""unescapedUrl"": ""http://www.imdb.com/name/nm0385296/"",
    ""url"": ""http://www.imdb.com/name/nm0385296/"",
    ""visibleUrl"": ""www.imdb.com"",
    ""cacheUrl"": ""http://www.google.com/search?q=cache:1i34KkqnsooJ:www.imdb.com"",
    ""title"": ""<b>Paris Hilton</b>"",
    ""titleNoFormatting"": ""Paris Hilton"",
    ""content"": ""Self: Zoolander. Socialite <b>Paris Hilton</b>...""
  }
  ]
}";

picture = @"{
  ""root"": [
  {
    ""status"": ""success"",
    ""filename"": ""b79d597b-bac5-4448-9443-9d0d388c97d7.jpg"",
    ""mainpic"": ""true"",
    ""fullurl"": ""../userimages/b79d597b-bac5-4448-9443-9d0d388c97d7.jpg""
  },
  {
    ""status"": ""success"", ""filename"": ""f232b9fb-edf0-41b2-802f-f98ecf502b1c.jpg"",
    ""mainpic"": ""true"",
    ""fullurl"": ""../userimages/f232b9fb-edf0-41b2-802f-f98ecf502b1c.jpg""
  }
  ]
}";

JObject googleSearch = JObject.Parse(googleSearchText).Dump();
JObject o = JObject.Parse(picture).Dump();
string googleSearchText=@”{
“结果”:[
{
“GsearchResultClass”:“GwebSearch”,
“unescapedul”:http://en.wikipedia.org/wiki/Paris_Hilton"",
“url”:”http://en.wikipedia.org/wiki/Paris_Hilton"",
“”visibleUrl”“:“”en.wikipedia.org”“,
“缓存URL”:”http://www.google.com/search?q=cache:TwrPfhd22hYJ:en.wikipedia.org"",
“标题”:“帕丽斯·希尔顿-维基百科,免费百科全书”,
“标题信息”:“帕丽斯·希尔顿-维基百科,免费百科全书”,
“内容”:“[1]2006年,她发行了她的首张专辑……”
},
{
“GsearchResultClass”:“GwebSearch”,
“unescapedul”:http://www.imdb.com/name/nm0385296/"",
“url”:”http://www.imdb.com/name/nm0385296/"",
“visibleUrl”“:”“www.imdb.com”“,
“缓存URL”:”http://www.google.com/search?q=cache:1i34KkqnsooJ:www.imdb.com"",
“头衔”:“帕丽斯希尔顿”,
“标题格式”:“帕丽斯希尔顿”,
“内容”:“自我:Zoolander.社交名媛帕丽斯·希尔顿…”
}
]
}";
图片=@“{
“根”:[
{
“状态”:“成功”,
“文件名”:“b79d597b-bac5-4448-9443-9d0d388c97d7.jpg”,
“mainpic”:“true”,
“完整URL”:“../userimages/b79d597b-bac5-4448-9443-9d0d388c97d7.jpg”
},
{
“状态:”“成功”“文件名:”“f232b9fb-edf0-41b2-802f-f98ecf502b1c.jpg”“,
“mainpic”:“true”,
“完整URL”“:”“../userimages/f232b9fb-edf0-41b2-802f-f98ecf502b1c.jpg”
}
]
}";
JObject googleSearch=JObject.Parse(googleSearchText.Dump();
JObject o=JObject.Parse(picture.Dump();

您尚未声明
picture
变量的类型,但除此之外,您的代码片段对我很有用。你在使用最新版本的Json.NET吗?这太奇怪了,我已经尝试了大约20次,每次都没有出现错误,我唯一做的事情就是把它包装在一个Try-Catch中,但它在我身上没有失败。哦,是的,我删除了.Dump()部分JObject o=JObject.Parse(图片);