如何将Json文件中的Json值插入orientDB

如何将Json文件中的Json值插入orientDB,orientdb,orientdb2.2,orientdb-2.1,Orientdb,Orientdb2.2,Orientdb 2.1,我是orientDB的新手。我想知道如何将json文件中的json值插入orientDB { "config": { "log": "debug" }, "source" : { "file": { "path": "D:\\New folder\\database.json" } }, "extractor" : { "json": {} }, "transformers" : [ { "merge": { "joinFieldNam

我是orientDB的新手。我想知道如何将json文件中的json值插入orientDB

{   "config": {
    "log": "debug"   },   "source" : {
    "file": { "path": "D:\\New folder\\database.json" }   },   "extractor" : {
    "json": {}   },   "transformers" : [
    { "merge": { "joinFieldName": "id", "lookup": "Account.id" } },
    { "vertex": { "class": "Account"} },
    { "edge": {
      "class": "Friend",
      "joinFieldName": "friends",
      "lookup": "Account.id",
      "unresolvedLinkAction": "CREATE"
    } },
    { "edge": {
      "class": "Enemy",
      "joinFieldName": "enemies",
      "lookup": "Account.id",
      "unresolvedLinkAction": "CREATE"
    } }   ],   "loader" : {
    "orientdb": {
      "dbURL": "D:\\InstalledSoftwares\\orientdb-3.0.8\\databases\\demodb",
      "dbUser": "root",
      "dbPassword": "vtg@123",
      "dbAutoDropIfExists": true,
      "dbAutoCreate": true,
      "standardElementConstraints": false,
      "tx": false,
      "wal": false,
      "batchCommit": 1000,
      "dbType": "graph",
      "classes": [{"name": "Account", "extends":"V"}, {"name": "Friend", "extends":"E"}, {"name": 'Enemy', "extends":"E"}],
      "indexes": [{"class":"Account", "fields":["id:integer"], "type":"UNIQUE_HASH_INDEX" }]
    }   } }
这是我用来从json文件插入json值的代码。如果我运行这段代码,意味着它会抛出如下错误

java.lang.IllegalArgumentException:文本不能为null

你能核实一下并帮我解决这个问题吗。
提前谢谢

我试过你的案子,效果很好

database.json

[ 
    { 
        "name": "Joe", 
        "id": 1, 
        "friends": [2,4,5], 
        "enemies": [6] 
    }, 
    { 
        "name": "Suzie", 
        "id": 2, 
        "friends": [1,4,6], 
        "enemies": [5,2] 
    } 
]
{   
  "config": {
    "log": "debug"   
  },
  "source" : {
    "file": { "path": "database.json" }   
  },
  "extractor" : {
    "json": {}   
  },
  "transformers" : [
    { "merge": { "joinFieldName": "id", "lookup": "Account.id" } },
    { "vertex": { "class": "Account"} },
    { "edge": {
      "class": "Friend",
      "joinFieldName": "friends",
      "lookup": "Account.id",
      "unresolvedLinkAction": "CREATE"
    } },
    { "edge": {
      "class": "Enemy",
      "joinFieldName": "enemies",
      "lookup": "Account.id",
      "unresolvedLinkAction": "CREATE"
    } }   ],   "loader" : {
    "orientdb": {
      "dbURL": "remote:localhost/db_name",
      "serverUser": "server_username",
      "serverPassword": "server_password",
      "dbUser": "db_username",
      "dbPassword": "db_password",
      "dbAutoDropIfExists": true,
      "dbAutoCreate": true,
      "standardElementConstraints": false,
      "tx": false,
      "wal": false,
      "batchCommit": 1000,
      "dbType": "graph",
      "classes": [{"name": "Account", "extends":"V"}, {"name": "Friend", "extends":"E"}, {"name": 'Enemy', "extends":"E"}],
      "indexes": [{"class":"Account", "fields":["id:integer"], "type":"UNIQUE_HASH_INDEX" }]
    }   } }

import.json

[ 
    { 
        "name": "Joe", 
        "id": 1, 
        "friends": [2,4,5], 
        "enemies": [6] 
    }, 
    { 
        "name": "Suzie", 
        "id": 2, 
        "friends": [1,4,6], 
        "enemies": [5,2] 
    } 
]
{   
  "config": {
    "log": "debug"   
  },
  "source" : {
    "file": { "path": "database.json" }   
  },
  "extractor" : {
    "json": {}   
  },
  "transformers" : [
    { "merge": { "joinFieldName": "id", "lookup": "Account.id" } },
    { "vertex": { "class": "Account"} },
    { "edge": {
      "class": "Friend",
      "joinFieldName": "friends",
      "lookup": "Account.id",
      "unresolvedLinkAction": "CREATE"
    } },
    { "edge": {
      "class": "Enemy",
      "joinFieldName": "enemies",
      "lookup": "Account.id",
      "unresolvedLinkAction": "CREATE"
    } }   ],   "loader" : {
    "orientdb": {
      "dbURL": "remote:localhost/db_name",
      "serverUser": "server_username",
      "serverPassword": "server_password",
      "dbUser": "db_username",
      "dbPassword": "db_password",
      "dbAutoDropIfExists": true,
      "dbAutoCreate": true,
      "standardElementConstraints": false,
      "tx": false,
      "wal": false,
      "batchCommit": 1000,
      "dbType": "graph",
      "classes": [{"name": "Account", "extends":"V"}, {"name": "Friend", "extends":"E"}, {"name": 'Enemy', "extends":"E"}],
      "indexes": [{"class":"Account", "fields":["id:integer"], "type":"UNIQUE_HASH_INDEX" }]
    }   } }
然后我运行了oetl.bat import.json,结果如下:

select from V
+----+-----+-------+----+-------------+-----+-------+-------+-------------------+-------------+--------+
|#   |@RID |@CLASS |id  |in_Friend    |name |friends|enemies|out_Friend         |out_Enemy    |in_Enemy|
+----+-----+-------+----+-------------+-----+-------+-------+-------------------+-------------+--------+
|0   |#17:0|Account|2   |[#21:0]      |Suzie|[1,4,6]|[5,2]  |[#24:0,#21:1,#22:1]|[#26:0,#27:0]|[#27:0] |
|1   |#17:1|Account|6   |[#22:1]      |     |       |       |                   |             |[#25:0] |
|2   |#18:0|Account|1   |[#24:0]      |Joe  |[2,4,5]|[6]    |[#21:0,#22:0,#23:0]|[#25:0]      |        |
|3   |#19:0|Account|4   |[#22:0,#21:1]|     |       |       |                   |             |        |
|4   |#20:0|Account|5   |[#23:0]      |     |       |       |                   |             |[#26:0] |
+----+-----+-------+----+-------------+-----+-------+-------+-------------------+-------------+--------+

希望能有所帮助


您好,您使用的是什么版本?你能发布另一个json文件吗?Thxi am使用orientdb-3.0.8版本[{“名称”:“乔”,“id”:1,“朋友”:[2,4,5],“敌人”:[6]},{“名称”:“苏西”,“id”:2,“朋友”:[1,4,6],“敌人”:[5,2]}]