I'm trying to use the new JSON capabilites in PostgreSQL 9.3 and I'm looking for a function that unescapes JSON, the oposite of to_json(anyelement).
Below is a sample JSON:
{"single_comment": "Fred said \"Hi.\"" ,
"comments_array": ["Fred said \"Hi.\"", "Fred said \"Hi.\"", "Fred said \"Hi.\""]}
The query:
SELECT json_array_elements(json_column->'comments_array')
returns as descibed in the documentation a SET OF JSON.
"Fred said \"Hi.\""
"Fred said \"Hi.\""
"Fred said \"Hi.\""
Is there a way to unescape the result, so I can have the following result:
Fred said "Hi."
Fred said "Hi."
Fred said "Hi."
In the documentation I don't see any function that can help me. Unfortunately insalling the PLV8 is not a option for me.
Any ideas are highly appreciated.
"Fred said \"Hi.\""just another way of writing 'Fred said "Hi."'`?json_each_textinstead ofjson_array_elements?json_array_elements_text(instead ofjson_array_elements) does just that. Might not have been available in 2013 :-)