質問

I recently downloaded VB-JSON, VB6 JSON Parser Class Library and I'm trying to get a specific field from JSON data structure, but whit no luck, what I'm doing wrong here?

I'm using code like this:

Dim p As Object
Set p = JSON.parse(strFormattedJSON)

Debug.Print p.Item("wins_ratio").Item("value")

Here is the JSON data (I can read "status" and "count", but I can't manage to get "wins_ratio" value from it.):

{
    "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
            }
        }
    }
}
役に立ちましたか?

解決

Try this code instead

Debug.Print p.Item("data").Item("507785480").Item("wins_ratio").Item("value")

Notice that you have to know the player ID. It looks as if it's possible that multiple player IDs and stats could be returned if the query calls for it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top