如何访问 JSON 数组的内部元素。我的 Json 对象如下:
"numRecommenders": 0,
"publicProfileUrl": "http://www.linkedin.com/pub/heena-vyas/16/786/826",
"positions": {
"total": 1,
"positionList": [
{
"id": "91286566",
"title": "senior executive",
"company": {
"name": "Reliance",
"industry": "Oil & Energy",
"type": "Public Company",
"size": "10,001+ employees"
},
"isCurrent": true
}
]
},
我想访问positions.positionList.company.name
. 我的要求是运行GroupCommand
如下:
GroupCommand cmd = new GroupCommand(collection,
null,
new BasicDBObject("positions.positionList.company.name", "Reliance"),
new BasicDBObject("count", 0),
"function(obj,prev) {prev.count++;}",
null);
使用上述代码访问“名称”不起作用。有人可以给我一个答案,为什么不呢?