Re: jsonb array-style subscripting

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: jsonb array-style subscripting
Date: 2015-08-17 21:25:28
Message-ID: 55D25148.5040002@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 08/17/2015 02:18 PM, Jim Nasby wrote:
> On 8/17/15 3:33 PM, Josh Berkus wrote:
>> Again, how do we handle missing keys? Just return NULL? or ERROR? I'd
>> prefer the former, but there will be arguments the other way.
>
> I've been wondering if we should add some kind of "strict" JSON. My big
> concern is throwing an error if you try to provide duplicate keys, but
> it seems reasonable that json_strict would throw an error if you try to
> reference something that doesn't exist.

Only if there's demand for it. Is there?

>> array/key ambiguity is going to be painful.
>
> JSON keys are required to be strings, so maybe it's OK to differentiate
> based on whether the index is a string or a number. Or perhaps we use
> different nomenclature (ie: {} for objects).

Well, we did get rid of all of those implicit conversions for a reason.
So maybe that's good enough? i.e.

json['a']['b'][1] = 5
"assign 5 as the first element in the array 'b' of object 'a'"

json['a']['b']['1'] = 5
"assign 5 to key '1' of object 'b' of object 'a'"

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-08-17 21:40:12 Re: why can the isolation tester handle only one waiting process?
Previous Message Tom Lane 2015-08-17 21:19:03 Re: jsonb array-style subscripting