Привет, мне нужен nelp для следующего json массива l oop. Мне нравится этот Instagram или пост в Facebook. У меня есть json вложенный массив. Я попробовал приведенный ниже код, но он мне не помог. Мне нужно посмотреть как этот пост Instagram ниже Прикрепленное изображение.
Я хочу получить профиль, лайки, комментарии, подробности публикации отдельно через l oop
Вывод: (например, если l oop через Record1 означает, что он получает все вложенные элементы, такие как ( profile, Post..et c)). Распечатывает вывод, как показано ниже image
Records1: сообщение в профиле likedetails commentdetails
Records2: сообщение в профиле likedetails commentdetails
Records3: сообщение в профиле likedetails commentdetails
Records4: сообщение в профиле likedetails комментарийdetails
Records5: сообщение в профиле likedetails комментарий commentdetails
render() {
var Json={
"AllPost":[
{
"User_Id":1,
"Username":"te",
"Records":[
{
"Profile":[{
"User_Id":"1",
"UserImage":"",
"Fullname":"Test",
"Username":"te"
}],
"Post":[{
"Post_Id":"1",
"UploadFile":"",
"Post_Caption":"Test",
"User_Id":"1"
}],
"likedetails":[{
"Post_Id":"1",
"LikeCount":"345"
}],
"commentdetails":[
{
"Comments":"testA",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testB",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testC",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testD",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testE",
"Username": "te",
"Comment_Date":"12-12-12"
}
]
}
]
},
{
"User_Id":2,
"Username":"te",
"Records":[
{
"Profile":[{
"User_Id":"2",
"UserImage":"",
"Fullname":"Test",
"Username":"te"
}],
"Post":[{
"Post_Id":"2",
"UploadFile":"",
"Post_Caption":"Test",
"User_Id":"2"
}],
"likedetails":[{
"Post_Id":"12",
"LikeCount":"3452"
}],
"commentdetails":[
{
"Comments":"testA",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testB",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testC",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testD",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testE",
"Username": "te",
"Comment_Date":"12-12-12"
}
]
}
]
},
{
"User_Id":3,
"Username":"te",
"Records":[
{
"Profile":[{
"User_Id":"3",
"UserImage":"",
"Fullname":"Test3",
"Username":"te3"
}],
"Post":[{
"Post_Id":"3",
"UploadFile":"",
"Post_Caption":"Test",
"User_Id":"3"
}],
"likedetails":[{
"Post_Id":"3",
"LikeCount":"345"
}],
"commentdetails":[
{
"Comments":"testA",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testB",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testC",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testD",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testE",
"Username": "te",
"Comment_Date":"12-12-12"
}
]
}
]
},
{
"User_Id":4,
"Username":"te",
"Records":[
{
"Profile":[{
"User_Id":"4",
"UserImage":"",
"Fullname":"Test4",
"Username":"te4"
}],
"Post":[{
"Post_Id":"4",
"UploadFile":"",
"Post_Caption":"Test4",
"User_Id":"4"
}],
"likedetails":[{
"Post_Id":"4",
"LikeCount":"3454"
}],
"commentdetails":[
{
"Comments":"testA",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testB",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testC",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testD",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testE",
"Username": "te",
"Comment_Date":"12-12-12"
}
]
}
]
},
{
"User_Id":5,
"Username":"te",
"Records":[
{
"Profile":[{
"User_Id":"5",
"UserImage":"",
"Fullname":"Test5",
"Username":"te5"
}],
"Post":[{
"Post_Id":"5",
"UploadFile":"",
"Post_Caption":"Test5",
"User_Id":"5"
}],
"likedetails":[{
"Post_Id":"5",
"LikeCount":"3455"
}],
"commentdetails":[
{
"Comments":"testA",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testB",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testC",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testD",
"Username": "te",
"Comment_Date":"12-12-12"
},
{
"Comments":"testE",
"Username": "te",
"Comment_Date":"12-12-12"
}
]
}
]
}
]
}
let arr=[];
Object.keys(Json.AllPost).forEach((records, index) => {
Json.AllPost[records].forEach((obj, idx) => {
arr.push(obj);
console.log(arr);
})
});
ex: codepen: https://codepen.io/dotnet345/pen/oNXBxBM