1

According to docs , jsonb_each_text(jsonb) returns

setof key text, value text

but if you pg_typeof(value) on result it shows jsonb, Eg:

SELECT *, pg_typeof(key) AS type_key, pg_typeof(value) AS type_value
FROM jsonb_each('{"2": "-200.08"}');

 key |   value   | type_key | type_value 
-----+-----------+----------+------------
 2   | "-200.08" | text     | jsonb

UPDATE: I have mistaken docs for jsonb_each_text instead of jsonb_each

1

jsonb_each is not jsonb_each_text

No, you're calling jsonb_each and you're referencing the docs for jsonb_each_text It shows

On \dfS json_each_text,

      Name       | Result data type |              Argument data types              |
-----------------+------------------+-----------------------------------------------+
 jsonb_each_text | SETOF record     | from_json jsonb, OUT key text, OUT value text 
 jsonb_each      | SETOF record     | from_json jsonb, OUT key text, OUT value jsonb 

Making that adjustment to call jsonb_each_text

SELECT *, pg_typeof(key) AS type_key, pg_typeof(value) AS type_value
FROM jsonb_each_text('{"2": "-200.08"}');

 key |  value  | type_key | type_value 
-----+---------+----------+------------
 2   | -200.08 | text     | text
  • 1
    According to postgresql docs, json_each_text(json) returns setof key text, value text, but json_each(json) returns setof key text, value json – McNets Dec 9 '16 at 18:34
  • Just that right after I posted and changed the answer. – Evan Carroll Dec 9 '16 at 18:35
  • Yes, I've seen now. – McNets Dec 9 '16 at 18:36
  • was I blind?... – Vao Tsun Dec 9 '16 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.