Re: Should the JSON datatype be a specialization of text? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Should the JSON datatype be a specialization of text?
Date
Msg-id 18096.1276793541@sss.pgh.pa.us
Whole thread Raw
In response to Re: Should the JSON datatype be a specialization of text?  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Should the JSON datatype be a specialization of text?  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Thu, Jun 17, 2010 at 11:25 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I'm
>> inclined to think that associating #2 with casts might be better,
>> because clearly casting numerics or bools to JSON ought to act like #2.
>> If we do it as you suggest then casting text to JSON behaves differently
>> from casting anything else to JSON.

> I think this is going to turn into a thicket of semantic ambiguity.

True.  Maybe it would be better to *not have* casts as such between JSON
and non-text data types, but make you write something likejson_literal(numeric)
to get a JSON literal representing a value.  Then json_literal(text)
would do an unsurprising thing (analogous to quote_literal), and we
could use the casts between text and json for the behavior where the
text is interpreted as a valid JSON object.

> Joseph's proposal also involved foo::text::json::text <> foo::text,
> which seems pretty ugly to me.

Agreed, that's not too nice.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Keepalive for max_standby_delay
Next
From: Andy Balholm
Date:
Subject: Re: ANNOUNCE list (was Re: New PGXN Extension site)