2

如果我的查询返回结果,我会尝试提取一些额外的信息。

例如,在此查询中,notable_for 返回为“/music/musical_group”,我想合并另一个查询以提取有关“/music/musical_group”的一些信息,例如其“名称”

[{
 "id": "/en/pearl_jam",
"mid":None,
"/common/topic/notable_for": [],
"name":[]   
}]

但是如果它没有返回任何我不希望我的查询失败的东西。例如,对于下面的查询,它为字段“notable_for”返回一个空列表

[{
"id": "/music/musical_group",
"mid":None,
"/common/topic/notable_for": [],
"name":[]
}]

为此,我应该如何封装我的查询?

4

2 回答 2

2

您选择了伪属性 (*/common/topic/notable_for*) 而不是真实属性作为示例,它的行为有点不同。对于不动产,如果您想获取所有子属性,可以使用@masouras 的简写符号 ([{}]) ,但如果您想选择一个或两个,诀窍是使用“可选”关键字。

例如,这个查询:

[{
  "id":  "/m/01mntvx",
  "type":"/music/musical_group",
  "/music/musical_group/member": [{
    "member": {
      "name": null
    },
    "optional": true
  }],
  "name":null
}]

即使乐队没有列出成员,也可以工作。

于 2012-01-03T22:29:48.203 回答
0

这是你要问的:

[{ "id": "/en/pearl_jam", "mid": null, "/common/topic/notable_for": [{}], }]​</p>

http://tinyurl.com/7tchree

于 2012-01-03T16:44:37.320 回答