Re: 9.3 Json & Array's

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Chris Travers <chris(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Adam Jelinek <ajelinek(at)gmail(dot)com>
Subject: Re: 9.3 Json & Array's
Date: 2013-09-24 12:46:43
Message-ID: 524189B3.4060601@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 09/24/2013 12:59 AM, Chris Travers wrote:
>
> I am still in the process of wrapping my head around the current JSON
> logic. I hope to produce a proof of concept that can later be turned
> into a patch. See my previous post on this topic. Again
> collaboration is welcome.
>
>

Feel free to ask questions.

The heart of the API is the event handlers defined in this stuct in
include/utils/jsonapi.h:

typedef struct JsonSemAction
{
void *semstate;
json_struct_action object_start;
json_struct_action object_end;
json_struct_action array_start;
json_struct_action array_end;
json_ofield_action object_field_start;
json_ofield_action object_field_end;
json_aelem_action array_element_start;
json_aelem_action array_element_end;
json_scalar_action scalar;
} JsonSemAction;

Basically there is a handler for the start and end of each non-scalar
structural element in JSON, plus a handler for scalars.

There are several problems that will be posed by processing nested
arrays and objects, including:

* in effect you would need to construct a stack of state that could be
pushed and popped
* JSON arrays aren't a very good match for SQL arrays - they are
unidimensional and heterogenous.

I'm not saying this can't be done - it will just take a bit of effort.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2013-09-24 12:48:56 Re: PostgreSQL 9.3 beta breaks some extensions "make install"
Previous Message Stephen Frost 2013-09-24 12:46:29 Re: Strange hanging bug in a simple milter