通过 VB6 从 JSON 获取特定字段 [英] Get specific field from JSON trough VB6

查看:61
本文介绍了通过 VB6 从 JSON 获取特定字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近下载了 VB-JSON,VB6 JSON 解析器类库,我正在尝试从 JSON 数据结构中获取特定字段,但没有运气,我在这里做错了什么?

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")

这是 JSON 数据(我可以读取状态"和计数",但我无法从中获取wins_ratio"值.):

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
            }
        }
    }
}

推荐答案

试试这个代码

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

请注意,您必须知道玩家 ID.如果查询需要它,看起来好像有可能返回多个玩家 ID 和统计数据.

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.

这篇关于通过 VB6 从 JSON 获取特定字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆