I need to convert some element in jsonb column to array
What I have:
{"a": {
"b": "2022-11-03",
"c": "321321",
"d": "213321"
}
}
What I need:
`
{"a": [
{
"b": "2022-11-03",
"c": "321321",
"d": "213321"
}
]
}
3
Answers
Use the "json_agg" function.
Example: db<>fiddle
Using function from here JSON functions and the The SQL/JSON Path Language. Use path language to decompose the original object and then jsonb_build_object to rebuild it in new form.
you can use
jsonb_set()
for this: