CREATE TABLE Log (
"Name" TEXT,
"Age" TEXT,
"Country" TEXT,
"Numbers" TEXT
);
SELECT "Country", "Numbers"
FROM json_populate_record( null:: log,
'{
"Name": "qazwsx",
"HostName": "Age",
"Address": {
"Country": "MNB",
"Numbers": [
{
"Cell": 7418520
}
]
}
}');
SELECT * FROM Log
DEMO: The response is always null. Is there any other trick to insert nested JSON into the table?
3
Answers
A quick and dirty example:
A little better version using the JSON path language from her JSON functions9.16.2. The SQL/JSON Path Language:
Though the above does depend on the ordering in the
Address
object staying the same.Output: