I have a JSON file gugu.json that looks like this:
{
"key1": {
"value1": "normal",
"value2": [
"PogU"
]
},
"key2": ...
}
I want to put all the contents of the JSON file into the table
KEKW(value1 text, value2 text, ...)
.
I already tried many thing like this:
CREATE TABLE gugu(
data json
);
\copy gugu FROM 'gugu.json';
SELECT * FROM json_populate_record(null::KEKW, (SELECT data->'key1' FROM gugu));
But as you can see I just don't know how I would get the "second level" of JSON in the table?
value2
? Where should the elements there go? or does that always contains exactly one element?"PogU"
value, what do you want to do with that array?