Monday, August 20, 2018

pasing json using javascript or jQuery [duplicate]

This question already has an answer here:

I have the following JSON code. How do I parse using JavaScript or jQuery an convert to variables: name, meetup tags ?

Here is my code:

{
    "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"
            ]
        }
    ]
}

Solved

Hopefully this will answer your question?

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

No comments:

Post a Comment