Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 键值递增的嵌套JSON_Javascript_Jquery_Json - Fatal编程技术网

Javascript 键值递增的嵌套JSON

Javascript 键值递增的嵌套JSON,javascript,jquery,json,Javascript,Jquery,Json,我试图读取一条嵌套的JSON消息,其中的键值是递增的整数值,但它似乎不起作用 $.each(data.post, function(entryIndex, entry) { $.each(this.entryIndex, function() { alert(this.username); }); }); 很抱歉,我试图将JSON代码粘贴到这里,但一直出现格式错误。相反,我上传了JSON 你的关卡太深了: $.each(data.posts, funct

我试图读取一条嵌套的JSON消息,其中的键值是递增的整数值,但它似乎不起作用

$.each(data.post, function(entryIndex, entry) {
    $.each(this.entryIndex, function() {
        alert(this.username);
    });
});

很抱歉,我试图将JSON代码粘贴到这里,但一直出现格式错误。相反,我上传了JSON

你的关卡太深了:

    $.each(data.posts, function() {

            alert(this.username);

    });​
请看这里:

这将为您获取回复的用户名:

    $.each(data.posts, function() {

        $.each(this.replies, function(){
            alert(this.username);
        });

    });​

我们可以看到您正在使用的JSON吗?你确定JSON字符串已经被解析成一个对象吗?你能提供JSON对象结构吗?也许它会包含一些示例数据?
    $.each(data.posts, function() {

        $.each(this.replies, function(){
            alert(this.username);
        });

    });​