我通过以下方式创建了一个嵌入式地图:
Map<String,Object> mapObjectToInsert = new HashMap<String, Object>();
mapObjectToInsert.put("attr1",1);
mapObjectToInsert.put("attr2","bla");
ODocument doc = new ODocument("testClass");
doc.field("postUrl","11");
doc.field("jsonData",mapObjectToInsert);
doc.save();
现在我有以下嵌入式地图:
{
"result": [
{
"@type": "d",
"@rid": "#14:0",
"@version": 1,
"@class": "testClass",
"postUrl": "11",
"postCategory": "#13:37",
"postDateImported": "2015-04-28 15:10:38",
"isBusniess": false,
"isPaid": false,
"postDateRead": "2015-04-28 15:10:33",
"jsonData": {
"attr1":"1"
"attr2":"bla"
},
"@fieldTypes": "postCategory=x,postDateImported=t,postDateRead=t"
}
],
"notification": "Query executed in 0.166 sec. Returned 1 record(s)"
}
我找到了
select expand(jsonData) from testClass
提供以下内容(地图的值):
{
"result": [
{
"@type": "d",
"@version": 0,
"value": "1"
},
{
"@type": "d",
"@version": 0,
"value": "bla"
}
],
"notification": "Query executed in 0.159 sec. Returned 2 record(s)"
}
但我希望能够从 jsonData (attr1和attr2)获取键名称 这样做的方法是什么? 谢谢!