Я пытаюсь разобрать строку JSON, но получаю странную ошибку:
Невозможно привести объект типа 'Newtonsoft.Json.Linq.JObject' к типу 'Newtonsoft.Json.Linq.JProperty'
Не могли бы вы проверить это и сообщить мне, как я могу получить title
значения из этой строки JSON!
[
{
"id":"14962106",
"title":"Why is Yahoo called Yahoo",
"link":"http:\/\/www.answers.com\/Q\/Why_is_Yahoo_called_Yahoo",
"is_answered":true
},
{
"id":"65001091",
"title":"Connecting yahoo IM to yahoo",
"link":"http:\/\/www.answers.com\/Q\/Connecting_yahoo_IM_to_yahoo",
"is_answered":true
},
{
"id":"45440021",
"title":"Why doesn't Yahoo recognize my Yahoo account",
"link":"http:\/\/www.answers.com\/Q\/Why_doesn%27t_Yahoo_recognize_my_Yahoo_account",
"is_answered":true
},
{
"id":"264383657",
"title":"How is Yahoo different from Yahoo Mail",
"link":"http:\/\/www.answers.com\/Q\/How_is_Yahoo_different_from_Yahoo_Mail",
"is_answered":true
},
{
"id":"11230021",
"title":"Does Yahoo block email",
"link":"http:\/\/www.answers.com\/Q\/Does_Yahoo_block_email",
"is_answered":true
},
{
"id":"11230461",
"title":"Is yahoo answers gone",
"link":"http:\/\/www.answers.com\/Q\/Is_yahoo_answers_gone",
"is_answered":true
},
{
"id":"12097857",
"title":"What is Yahoo BrowserPlus",
"link":"http:\/\/www.answers.com\/Q\/What_is_Yahoo_BrowserPlus",
"is_answered":true
},
{
"id":"100301924",
"title":"Is yahoo answers useful",
"link":"http:\/\/www.answers.com\/Q\/Is_yahoo_answers_useful",
"is_answered":true
},
{
"id":"107057666",
"title":"Are yahoo emails free",
"link":"http:\/\/www.answers.com\/Q\/Are_yahoo_emails_free",
"is_answered":true
},
{
"id":"107858033",
"title":"Is yahoo games free",
"link":"http:\/\/www.answers.com\/Q\/Is_yahoo_games_free",
"is_answered":true
}
]
JArray theamackersSuggesionResult = JArray.Parse(json);
foreach (JObject parsedObject in theamackersSuggesionResult.Children<JObject>())
{
foreach (JProperty parsedProperty in theamackersSuggesionResult)
{
string propertyName = parsedProperty.Name;
if (propertyName == "title")
{
MessageBox.Show(parsedProperty.Value.ToString());
KeywordSuggestionTable.Rows.Add(parsedProperty.Value.ToString());
KeywordResultDataGrid.Refresh();
}
}
}