MySQL Forums
Forum List  »  Other Migration

Trying to Load JSON data into MySql table
Posted by: Jason Wisdom
Date: January 02, 2023 06:44AM

Hi!

I have used MySql for over 10 years but am trying to use JSON data type for the first time, and having trouble importing a JSON file using LOAD DATA LOCAL INFILE.

Here is my MySql command:

load data local infile '/www/var/html/import/twoethtransactions.json' into table blockscan(jsondata);

blockscan table has two columns, one is id (identity, pk) and the other is jsondata (json).

--

Here is the error I get:

Error Code: 3140. Invalid JSON text: "Missing a name for object member." at position 2 in value for column 'blockscan.jsondata'.


Thoughts? What am I missing?
Many thanks,
Jason

---------------

Here is the json file, stripped down to two records (actual file has hundreds but error is the same):

{
"transactions": [
{
"id": "0xb28031dffb484f387c978ec8bec318cf0603cc7dbd57aa37612af29c40aa1544",
"timestamp": 1609870046,
"tx_hash": "0xb28031dffb484f387c978ec8bec318cf06099c7dbd57dd37612af29c40aa1544",
"from_address": "0xf6192d7c20092a2f2e403f643643b1824be108ca",
"to_address": "0xf6094c3a380ad6109fb8240f3043392a0e427cac",
"value": 0,
"fee_value": 0.009330958,
"fee_coin": {
"token_id": "ETH",
"token_symbol": "ETH"
},
"token_symbol": {
"token_id": "ETH",
"token_symbol": "ETH"
},
"source": 1,
"block_number": 11596060,
"error": null,
"contract_call": true
},
{
"id": "0x547c536f5ca8a96f98b177488c26f49472e2c92fc1df2a7cb60ffcbbc8abb03a",
"timestamp": 1609871195,
"tx_hash": "0x547c536f5ca8a96f98b171188c23849472e2c92fc1df2a7cb60ffcbbc8abb03a",
"from_address": "0xfe1b5e5260d320eb836abf5279d0381dda29670b",
"to_address": "0xf6094c3a380be6161fb8240f3043392a0e427cac",
"value": 0,
"fee_value": 0.0047019636,
"fee_coin": {
"token_id": "ETH",
"token_symbol": "ETH"
},
"token_symbol": {
"token_id": "ETH",
"token_symbol": "ETH"
},
"source": 1,
"block_number": 11596162,
"error": null,
"contract_call": true
}
]
}

Options: ReplyQuote


Subject
Views
Written By
Posted
Trying to Load JSON data into MySql table
46
January 02, 2023 06:44AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.