jquery - 使用 jquery 的 JSON 循环

标签 jquery json loops

读完这里的一些问题后,我仍然很难循环遍历我的 JSON 结果。 它们在这里:

{
    "data": {
        "posts": [
            {
            "Post": {
                "id": "1",
                "user_id": "1",
                "title": "Test Content",
                "created": "2011-06-30"
                }
            },
            {
                "Post": {
                "id": "2",
                "user_id": "2",
                "title": "New Test Content",
                "created": "2011-06-30"
                }
            }
        ]
    }
}

如何使用 $.each() 获取 Post.title ?

最佳答案

$.each(jsonObject.data.posts, function(index, val){
    alert(val.Post.title); //Do what you want to the title
});

关于jquery - 使用 jquery 的 JSON 循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6542378/

相关文章:

javascript - 如何在文本区域中按空格键然后退格键: using JQuery?

javascript - 如何处理jquery中div id中的空格

c# - 如何使用关键字作为属性名称?

c++ - 为什么如果我输入一个字母,我的程序就会陷入 while 循环?

java - 返回java中循环中存在的值

jquery - 无限滚动(Waypoints),带有 jQ​​uery Mobile、后退按钮和远程脚本调用两次

javascript - jQuery Reel 插件动态加载卷轴图像

php - 读取由 PHP 生成的包含 @attributes 的 JSON(使用 jQuery)

javascript - 在Javascript中寻找一种将具有重复数据的列样式数组转换为对象的方法

ios - 从循环更新 View