Re: JSON manipulation functions

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: JSON manipulation functions
Дата
Msg-id AANLkTilddD_hjKxBh1MPFF3LIijnjzo6MA7Ebinw_vll@mail.gmail.com
обсуждение исходный текст
Ответ на Re: JSON manipulation functions  (Joseph Adams <joeyadams3.14159@gmail.com>)
Список pgsql-hackers
On Fri, May 14, 2010 at 10:35 PM, Joseph Adams
<joeyadams3.14159@gmail.com> wrote:
> By the way, I'm considering making it so JSON arrays will be treated
> like objects when it comes to -> and the json_keys function.  Thus,
> json_keys('[1,4,9,16,25]') would yield '{1,2,3,4,5}', and
> ('[1,4,9,16,25]'::JSON) -> 3 would yield the third item.  This would
> obviate the need for an array-only subscript function/operator.
>
> In general, I prefer zero-based counting, but because PostgreSQL's
> array indexing is one-based, one-based array keys would be better for
> the sake of consistency.  Note that if there was a function like this
> in the future:
>
> -- Access a JSON object like you would in JavaScript
> json_path('{"squares": [1,4,9,16,25]}', '.squares[2]')
>
> There could be confusion, as JavaScript uses zero-based indexing.

I think you should take Tom's suggestion and use functional notation
rather than operator notation.  And then I think you should use
0-based counting to match JS.  But I'm game to be outvoted if others
disagree.  Basically, I think you're right: it will be confusing to
have two different notations, and we're certainly going to want a JS
equivalent of XPath at some point.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Joseph Adams
Дата:
Сообщение: Re: JSON manipulation functions
Следующее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: List traffic