January 31st, 2014 by depesz | Tags: , , , | No comments »
Did it help? If yes - maybe you can help me?

On 29th of January, Andrew Dunstan committed patch:

Add json_array_elements_text function.
 
This was a notable omission from the json functions added in 9.3 and
there have been numerous complaints about its absence.
 
Laurence Rowe.

Yet another JSON support function. This time just one, and, looks rather simple. When you have JSON array, you can extract each value as text:

$ select * from json_array_elements_text('["postgresql", "depesz", "universe"]'::json);
   value    
------------
 postgresql
 depesz
 universe
(3 rows)

If any of the elements are non scalar – it just shows json representation:

$ select * from json_array_elements_text('["postgresql", "depesz", "universe", [1,2,3], {"a":1, "b":2}]'::json);
     value      
----------------
 postgresql
 depesz
 universe
 [1,2,3]
 {"a":1, "b":2}
(5 rows)

Simple, but it makes me happy, as it shows that we have general interest in JSON support. Cool.

Leave a comment