使用javascript或jQuery解析json

时间:2014-11-07 15:39:21

标签: javascript jquery json

我有以下JSON代码。如何使用JavaScript或jQuery解析转换为变量:namemeetup标签?

这是我的代码:

{
    "MYID": 1,
    "module": [
        {
            "name": "Manchester",
            "meetup": "First Monday of every month",
            "tags": [
                "gtug",
                "google",
                "manchester",
                "madlab"
            ]
        },
        {
            "name": "jQuery Group",
            "meetup": "First Tuesday of every month",
            "tags": [
                "jquery",
                "javascript",
                "jresig",
                "madlab"
            ]
        },
        {
            "name": "Hybrid!",
            "meetup": "First Monday of every month",
            "tags": [
                "jquery",
                "javascript",
                "jresig",
                "madlab"
            ]
        }
    ]
}

1 个答案:

答案 0 :(得分:0)

希望这会回答你的问题吗?

var json = JSON.parse("...");
for (var i = 0; i < json.module.length; i++) {
    var mod = json.module[i];

    var name = mod.name;
    var meetup = mod.meetup;
    var tags = mod.tags;
}