sách gpt4 ai đã đi

json - 遍历 JSON 对象的正确方法

In lại 作者:可可西里 更新时间:2023-11-01 10:00:24 27 4
mua khóa gpt4 Nike

Since there seems nobody is able to find a solution for my problem ,我想以不同的方式问我的问题:遍历以下对象的游戏部分的正确方法应该是什么:

[
{
"_id": "5710b0ddab8b724011705037",
"username": "test",
"name": "testuser",
"__v": 0,
"library": {
"games": [
{
"platform": [
"17",
"94"
],
"name": "Simcity",
"id": "37620"
},
{
"platform": [
"146",
"20"
],
"name": "destiny",
"id": "36067"
}
],
"platforms": [
{
"name": "Xbox360",
"id": "20"
},
{
"name": "PC",
"id": "94"
}
]
}
}
]

这个对象是通过 mongoose 从 MongoDB 中提取出来的,所有这些都发生在我的 NodeJS 应用程序的 API 部分:

.get('/test', function(req, res){
User.findOne({"username": req.decoded.username}, function(err, user){

// trying to loop here

});
})

我已经尝试了我找到的所有方法,但我无法让它工作,所以我想知道你用什么方法来做到这一点,而不用我的(可能是错误的)方法和错误来扰乱你的视野......

27 4 0
可可西里
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com