我最近下载了VB-JSON,VB6 JSON Parser类库,我正试图从JSON数据结构中获取一个特定的字段,但是没有运气,我在这里做错了什么?
我正在使用这样的代码:
Dim p As Object
Set p = JSON.parse(strFormattedJSON)
Debug.Print p.Item("wins_ratio").Item("value")
这是JSON数据(我可以读取“status”和“count”,但我无法从中获得“wins_ratio”值。):
{
"status": "ok",
"count": 1,
"data": {
"507785480": {
"survived_ratio": {
"rank_delta": -10,
"value": 48.23,
"rank": 1202
},
"capture_points": {
"rank_delta": null,
"value": null,
"rank": null
},
"wins_ratio": {
"rank_delta": -31,
"value": 55.37,
"rank": 34239
},
"account_id": 507785480,
"frags_avg": {
"rank_delta": null,
"value": null,
"rank": null
},
"frags_count": {
"rank_delta": 505,
"value": 12790,
"rank": 105081
},
"xp_amount": {
"rank_delta": null,
"value": null,
"rank": null
},
"hits_ratio": {
"rank_delta": 444,
"value": 62.09,
"rank": 325157
},
"spotted_avg": {
"rank_delta": null,
"value": null,
"rank": null
},
"xp_avg": {
"rank_delta": 949,
"value": 463.52,
"rank": 240448
},
"damage_dealt": {
"rank_delta": 526,
"value": 5968315,
"rank": 279134
},
"spotted_count": {
"rank_delta": null,
"value": null,
"rank": null
},
"xp_max": {
"rank_delta": -165,
"value": 2422,
"rank": 145254
},
"damage_avg": {
"rank_delta": null,
"value": null,
"rank": null
},
"battles_to_play": 0,
"battles_count": {
"rank_delta": 1159,
"value": 9778,
"rank": 241038
},
"global_rating": {
"rank_delta": -125,
"value": 6772,
"rank": 72401
}
}
}
}
答案 0 :(得分:1)
尝试使用此代码
Debug.Print p.Item("data").Item("507785480").Item("wins_ratio").Item("value")
请注意,您必须知道玩家ID。如果查询要求,可能会返回多个玩家ID和统计数据。