如何在json文件上连接两个集合pr对象? [英] How to connect between two collection pr object on json file?
本文介绍了如何在json文件上连接两个集合pr对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的json文件中有两个不同的对象,我想用systemName的属性连接它们。
怎么办?
这是事件对象的样子:
我希望从Systems对象中获取包含所有系统名称列表的systemName。
{
_id:ObjectId(5ad8764465639315a4e54e39),
yellowEvents:1,
redEvents:1,
命令:测试,
systemName:armyEG,
__ v:0
}
这是System对象的样子:
{
_ id:ObjectId(5ad86abc6837621e309671a3),
systemName:armyTS,
__ v:0
},
{
_id:ObjectId(5ad86abc6837621e309671a3),
systemName:armyIL,
__ v:0
},
{
_id :ObjectId(5ad86abc6837621e309671a3),
systemName:armyEG,
__v:0
},
{
_id:ObjectId(5ad86abc6837621e309671a3),
systemName:armyRU,
__ v :0
}
我尝试过:
i试图这样做:
{
_id:ObjectId(5ad8764465639315a4e54e39 ),
yellowEvents:1,
redEvents:1,
命令:test,
systemName:System [2] .systemName ,
__ v:0
}
解决方案
使用JSON - 学习Web开发| MDN [ ^ 一>
i have two diffrent object on my json file and i want to connect between them with the attribute of systemName.
how to do so?
this is how the event object look like:
and i want to get the systemName from the Systems object the contain all the systems name List.
{ "_id" : ObjectId("5ad8764465639315a4e54e39"), "yellowEvents" : 1, "redEvents" : 1, "commands" : "test", "systemName" : "armyEG", "__v" : 0 }
this is how the System object look like :
{ "_id" : ObjectId("5ad86abc6837621e309671a3"), "systemName" : "armyTS", "__v" : 0 }, { "_id" : ObjectId("5ad86abc6837621e309671a3"), "systemName" : "armyIL", "__v" : 0 }, { "_id" : ObjectId("5ad86abc6837621e309671a3"), "systemName" : "armyEG", "__v" : 0 }, { "_id" : ObjectId("5ad86abc6837621e309671a3"), "systemName" : "armyRU", "__v" : 0 }
What I have tried:
i have tried to do like this:
{ "_id" : ObjectId("5ad8764465639315a4e54e39"), "yellowEvents" : 1, "redEvents" : 1, "commands" : "test", "systemName" : "System[2].systemName", "__v" : 0 }
解决方案
Working with JSON - Learn web development | MDN[^]
这篇关于如何在json文件上连接两个集合pr对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文