如果我的查询返回结果,我会尝试提取一些额外的信息。
例如在此查询中,notable_for返回为“/ music / musical_group”,我想合并另一个查询以提取有关“/ music / musical_group”的一些信息,如“name”
[{
"id": "/en/pearl_jam",
"mid":None,
"/common/topic/notable_for": [],
"name":[]
}]
但如果它没有返回任何我不希望我的查询失败。例如,对于下面的查询,它返回字段“notable_for”
的空列表[{
"id": "/music/musical_group",
"mid":None,
"/common/topic/notable_for": [],
"name":[]
}]
我应该如何为此目的包裹我的查询?
答案 0 :(得分:2)
您选择了一个伪表(* / common / topic / notable_for *)而不是一个不动产作为示例,它的行为略有不同。对于不动产,如果你想获得所有子属性,你可以使用@ masouras的简写符号([{}]),但如果你想选择一个或两个,那么诀窍是使用“可选”关键字。
例如,此查询:
[{
"id": "/m/01mntvx",
"type":"/music/musical_group",
"/music/musical_group/member": [{
"member": {
"name": null
},
"optional": true
}],
"name":null
}]
即使乐队没有列出成员,也会有效。
答案 1 :(得分:0)
这就是你要问的问题:
[{ “id”:“/ en / pearl_jam”, “mid”:null, “/ common / topic / notable_for”:[{}], }]