[英]How to insert Json values from json file into orientDB
I am new to orientDB.我是 orientDB 的新手。 I want to know how to insert json values from json file into 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" }]
} } }
this is the code i am using to insert json values from json file.这是我用来从 json 文件插入 json 值的代码。 If i run this code means it throws an error like如果我运行此代码意味着它会引发类似的错误
java.lang.IllegalArgumentException: text cannot be null java.lang.IllegalArgumentException:文本不能为空
Can you plz verify this and help me to fix this.你能验证一下并帮助我解决这个问题吗? Thanks in Advance提前致谢
I tried your case and it worked我试过你的情况,它奏效了
database.json数据库.json
[
{
"name": "Joe",
"id": 1,
"friends": [2,4,5],
"enemies": [6]
},
{
"name": "Suzie",
"id": 2,
"friends": [1,4,6],
"enemies": [5,2]
}
]
import.json导入文件
{
"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" }]
} } }
then I ran oetl.bat import.json and this is what I get:然后我运行 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] |
+----+-----+-------+----+-------------+-----+-------+-------+-------------------+-------------+--------+
Hope it helps希望能帮助到你
Regards问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.