Let's say I have this json format:
[
{
"firstName": "John",
"lastName": "Doe"
}
]
and I want to delete the "lastName", how can I do that?
So far I have this query and it works, but the problem is it adds another array
UPDATE person
SET
field = jsonb_set(field::jsonb,
'{0}',
field::jsonb #- '{0,lastName}',
false)
The result from my query above:
[
[
{
"firstName": "John"
}
]
]
The result that I want:
[
{
"firstName": "John"
}
]