Hello All,
I was able to get the name and country of JSON array below if it starts with a curly bracket:
{"items":[{"name": "MyFirstCompany","country": "DE"},{"id": 2,"name": "MySecondCompany", "country": "DE"}]}
using this SQL command:
with y as (
Select * from JSON_TABLE(get_clob_from_file('/test.json'), '$'
columns( nested '$.items[*]' columns(
"name" varchar(30),
"country" varchar(02)
) ) ) x ) select * from y with ur;
However, the JSON data I want to parse starts with a square bracket and looks like this:
'[{"name": "MyFirstCompany","country": "DE"},{"id": 2,"name": "MySecondCompany", "country": "DE"}]'
But I wasn't able to get any rows using this command:
with y as (
Select * from JSON_TABLE(
'[{"name": "MyFirstCompany","country": "DE"},{"id": 2,"name": "MySecondCompany", "country": "DE"}]', '$'
columns(
nested 'lax $[*]' columns(
"name" varchar(30),
"country" varchar(02)
) ) ) x
) select * from y with ur;
Kindly advise on correct command on parsing JSON array that starts with a square bracket.
Thanks,
Lynelle
________________________________
This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. Your privacy is important to us. Accenture uses your personal data only in compliance with data protection laws. For further information on how Accenture processes your personal data, please see our privacy statement at
https://www.accenture.com/us-en/privacy-policy.
______________________________________________________________________________________
www.accenture.com
As an Amazon Associate we earn from qualifying purchases.