我在C#中使用JSON.NET來解析來自Klout API的響應。我的回覆是這樣的:在C#中迭代JSON對象#
[
{
"id": "5241585099662481339",
"displayName": "Music",
"name": "music",
"slug": "music",
"imageUrl": "http://kcdn3.klout.com/static/images/music-1333561300502.png"
},
{
"id": "6953585193220490118",
"displayName": "Celebrities",
"name": "celebrities",
"slug": "celebrities",
"imageUrl": "http://kcdn3.klout.com/static/images/topics/celebrities_b32741b6703151cc7bd85fba24c44c52.png"
},
{
"id": "5757029936226020304",
"displayName": "Entertainment",
"name": "entertainment",
"slug": "entertainment",
"imageUrl": "http://kcdn3.klout.com/static/images/topics/Entertainment_7002e5d2316e85a2ff004fafa017ff44.png"
},
{
"id": "3718",
"displayName": "Saturday Night Live",
"name": "saturday night live",
"slug": "saturday-night-live",
"imageUrl": "http://kcdn3.klout.com/static/images/icons/generic-topic.png"
},
{
"id": "8113008320053776960",
"displayName": "Hollywood",
"name": "hollywood",
"slug": "hollywood",
"imageUrl": "http://kcdn3.klout.com/static/images/topics/hollywood_9eccd1f7f83f067cb9aa2b491cd461f3.png"
}
]
如您所見,它包含5個id
標籤。也許下次它會是6或1或其他數字。我想迭代JSON並獲取每個id
標記的值。不知道會有多少人,我無法運行循環。我該如何解決這個問題?
它說,失蹤參考Micrsofot.CSHARp和System.Core.I添加參考both.It的APS.NET應用 –
不幸的是「動態」的關鍵字可從框架4.0起:( –