I am using the Postgres database in one of the projects. Now I have a requirement to store JSON array in a database. Something like below:
For e.g., I have below JSON structure:
[
{
"Id": 1,
"Name": "XYZ"
},
{
"Id": 2,
"Name": "ABC"
}
]
For this purpose, I am using JSONB datatype and it works fine. Then what it is the use of JSONB[] datatype when we can simply store a JSON array in JSONB datatype?
jsonb[]is not an "extra" datatype, it's simply an array of JSONB values. Similar totext[]orinteger[]. You can create arrays from every type. But I do agree that using an arrayjsonbhardly ever makes sense.