4 ms·
No, it can be a gotcha because the json column type (which still exists and many may mistakenly use instead of the jsonb type) allows it: select '{"foo": 1, "f
by qooleot 12y ago
No, it can be a gotcha because the json column type (which still exists and many may mistakenly use instead of the jsonb type) allows it:
select '{"foo": 1, "foo": 2}'::json;
json
----------------------
{"foo": 1, "foo": 2}
(1 row)
select '{"foo": 1, "foo": 2}'::jsonb;
jsonb
------------
{"foo": 2}
(1 row)
So technically, the gotcha is you have to remember to use jsonb instead of json, as well as json having a true "gotcha" and jsonb not having one.
- ak4g 12y agothe json type just stores the string value passed to it, but only the final value is available to the JSON-aware operators. mydb=# select ('{"foo": 1, "foo": 2}'::jsonb)->'foo' jsonb_foo, ('{"foo": 1, "foo": 2}'::json)->'foo' json_foo; jsonb_foo|2 json_foo|2