I have a function returning jsonb records
SELECT get_my_records( 'some', 'args' );
{ "a": 1, "b": 3.14 }
{ "a": 2, "b": 2.71 }
...
and trying to use jsonb_to_record()
to convert the records to
a | b
--+-----
1 | 3.14
2 | 2.71
...
Tried
SELECT * FROM jsonb_to_record( val ) as x( a int, b double precision ) FROM get_my_records( 'some', 'arg' ) AS val;
and a few variations but without success. How does one go about it?
(probably lacking proper terminology to get meaningful results from the web search)
2
Answers
Here how to do it using
jsonb_to_record()
:Or simply using the operator
->>
:You were mostly correct in what you did, but you added multiple
FROM
lists: fiddle