JSon.Net JObject.Parse - PullRequest
       5

JSon.Net JObject.Parse

1 голос
/ 23 февраля 2012

В приведенном ниже коде я использую Json.net. По какой-то причине этот код ошибки на мне на
JObject o = JObject.Parse(picture);
но работает на
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();
...