精易论坛

标题: json 解析问题 [打印本页]

作者: gytxtx    时间: 2024-2-19 14:33
标题: json 解析问题
例如,这是一段 json 数据

[JavaScript] 纯文本查看 复制代码
{
    "online": true,
    "host": "demo.mcstatus.io",
    "port": 19132,
    "ip_address": "144.172.70.183",
    "eula_blocked": false,
    "retrieved_at": 1681884126942,
    "expires_at": 1681884186942,
    "version": {
        "name": "1.19.70",
        "protocol": 575
    },
    "players": {
        "online": 71,
        "max": 100
    },
    "motd": {
        "raw": "A Bedrock server\nYou cannot connect!",
        "clean": "A Bedrock server\nYou cannot connect!",
        "html": "<span><span style=\"color: #ffffff;\">A Bedrock server</span><span style=\"color: #ffffff;\">\nYou cannot connect!</span></span>"
    },
    "gamemode": "Survival",
    "server_id": "8919800251809186875",
    "edition": "MCPE"
}


我想解析 "players" 的内容,并且解析出 "online" 与 "max" 属性的内容

求大佬给出答案(源代码或附件形式),谢谢!

Minecraft Server Status.e (962.71 KB, 下载次数: 3)

这是源代码,调用了精易模块





作者: 616    时间: 2024-2-19 14:33
  
变量名类 型静态数组备 注
Json类_json 
Json.解析 ( #常量1 )
调试输出 (Json.取通用属性 (“players.online”, ))
调试输出 (Json.取通用属性 (“players.max”, ))


i支持库列表   支持库注释   
spec特殊功能支持库

作者: gytxtx    时间: 2024-2-19 14:47
616 发表于 2024-2-19 14:41
[e=3].版本 2
.支持库 spec

非常好的解决方案




欢迎光临 精易论坛 (https://125.confly.eu.org/) Powered by Discuz! X3.4