我收到了OCommandSQLParsingException: 解析位置#0处的命令时出错:无效关键字:" TYPE":" PERSON"
on
ODocument doc = new ODocument(json);
json字符串是:
{"Salary":1500.0,"Type":"Person","Address":[{"Zip":"JX2 MSX","Type":"Home","Street1":"13 Marge Street","Country":"Holland","Id":"Address-28813211","City":"Amsterdam","From":"1996-02-01","To":"1998-01-01"},{"Zip":"90210","Type":"Work","Street1":"100 Hollywood Drive","Country":"USA","Id":"Address-11595040","City":"Los Angeles","From":"2009-09-01"}],"Id":"Person-7464251","Name":"Stan"}
我已尝试过2.1-rc1和2.0.7社区版发布。
答案 0 :(得分:1)
从JSON创建ODocument的正确方法是使用.fromJSON()API:
public void testOtherJson(){
new ODocument().fromJSON("{\"Salary\":1500.0,\"Type\":\"Person\",\"Address\":[{\"Zip\":\"JX2 MSX\",\"Type\":\"Home\",\"Street1\":\"13 Marge Street\",\"Country\":\"Holland\",\"Id\":\"Address-28813211\",\"City\":\"Amsterdam\",\"From\":\"1996-02-01\",\"To\":\"1998-01-01\"},{\"Zip\":\"90210\",\"Type\":\"Work\",\"Street1\":\"100 Hollywood Drive\",\"Country\":\"USA\",\"Id\":\"Address-11595040\",\"City\":\"Los Angeles\",\"From\":\"2009-09-01\"}],\"Id\":\"Person-7464251\",\"Name\":\"Stan\"}");
}