Thread: revert function for to_json ?

revert function for to_json ?

From
Marc Mamin
Date:
Hello,
 
I'm looking for $subject
 
example:
 
how to revert
  select to_json(E'a\n''b'::text)
 
I can achieve it with something like this:
  select json_extract_path_text(('{"a":'||to_json(E'a\n''b'::text)||'}')::json,'a')
 
does anybody knows a  less ugly solution ?
 
regards,
 
Marc Mamin
 

Re: revert function for to_json ?

From
Marc Mamin
Date:
>From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Marc Mamin
>Sent: Montag, 23. Mai 2016 16:03
>To: pgsql-general@postgresql.org
>Subject: [GENERAL] revert function for to_json ?
>
>Hello,
>
>I'm looking for $subject
>
>example:
>
>how to revert
>  select to_json(E'a\n''b'::text)
>
>I can achieve it with something like this:
>  select json_extract_path_text(('{"a":'||to_json(E'a\n''b'::text)||'}')::json,'a')
>
>does anybody knows a  less ugly solution ?

I just  found the solution here:
http://stackoverflow.com/questions/27215216/postgres-how-to-convert-json-string-to-text

:-)

select to_json(E'a\n''b'::text)#>>'{}'



>
>regards,
>
>Marc Mamin
>