Unpacking scalar JSON values

From: Daniel Farina <daniel(at)fdr(dot)io>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Unpacking scalar JSON values
Date: 2013-08-24 21:36:56
Message-ID: CACN56+P8irXUQv168x8-2Sqk4T=4CruyZ+wKohAAnz41rw+z7A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Per report of Armin Ronacher, it's not clear how to take a scalar JSON
string and unquote it into a regular Postgres "text" value, given what
I can see here:
http://www.postgresql.org/docs/9.3/static/functions-json.html

Example:

SELECT '"a json string"'::json;

(Although this some problem could play out with other scalar JSON types):

SELECT '4'::json;
SELECT '2.0'::json;

This use cases arises from some of the extant unpacking operations,
such as json_array_elements. It's not that strange to have a value
something something like this in a JSON:

'{"tags": ["a \" string", "b", "c"]}'

Thoughts?

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2013-08-24 22:09:28 Re: Unpacking scalar JSON values
Previous Message Fabien COELHO 2013-08-24 20:06:21 Re: pgbench progress report improvements