从json字符串下面获取数据

时间:2015-06-18 12:54:05

标签: javascript json

我想获得" text"的价值从下面的代码与JavaScript。任何帮助将不胜感激。



<script> require("InitialJSLoader").handleServerJS({
    
    "require": [

        ["ODNavigation", "setPageQuery", [],
            [{
                "structure": [{
                    "text": "name",
                    "type": "none",
                    "uid": 00001
                }],
                "semantic": null
            }]
        ]
    ]
});
</script>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

r = {"require": [

    ["ODNavigation", "setPageQuery", [],
        [{
            "structure": [{
                "text": "name",
                "type": "none",
                "uid": 00001
            }],
            "semantic": null
        }]
    ]
]}

r.require[0][3][0].structure[0].text // return "name"

答案 1 :(得分:0)

&#13;
&#13;
var obj = {
    "require": [

        ["ODNavigation", "setPageQuery", [],
            [{
                "structure": [{
                    "text": "name",
                        "type": "none",
                        "uid": 00001
                }],
                    "semantic": null
            }]
        ]
    ]
};
var text = obj.require[0][3][0].structure[0].text;
alert(text);
&#13;
&#13;
&#13;