Re: PATCH: Add hstore_to_json()

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PATCH: Add hstore_to_json()
Date: 2010-01-04 08:35:06
Message-ID: e08cc0401001040035t2e2ae79aqe7210935bc40a044@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2010/1/4 David E. Wheeler <david(at)kineticode(dot)com>:
> On Jan 3, 2010, at 4:18 PM, Hitoshi Harada wrote:
>
>> That sounds good and seems possible, as far as operator returns JSON
>> always. Perhaps every JSON fetching returns JSON even if the result
>> would be a number. You can cast it.
>>
>>   % SELECT ('{"foo":{"bar":["a","b","c"]}}' -> '["foo"][1]')::text;
>>    1
>>   -----
>>    b
>
> No, because 'b' isn't valid JSON. So if we want an interface that returns scalars, they can't be JSON.

AFAIK string value can be parsed as JSON. At least my local v8 shell answers:

> JSON.stringify({"foo": {"bar": ["a", "b", "c"]}})
{"foo":{"bar":["a","b","c"]}}

> JSON.stringify("b")
"b"

Regards,

--
Hitoshi Harada

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Scara Maccai 2010-01-04 09:30:04 TODO: Allow substring/replace() to get/set bit values
Previous Message Simon Riggs 2010-01-04 08:04:35 Re: New VACUUM FULL