Re: SQLJSON - Mailing list pgsql-jdbc

From Dave Cramer
Subject Re: SQLJSON
Date
Msg-id CADK3HHLHxztk8gBYYxg4yTkRx=pPJbyT-3mxOqPX6W3aa3tXTg@mail.gmail.com
Whole thread Raw
In response to Re: SQLJSON  (Steven Schlansker <stevenschlansker@gmail.com>)
Responses Re: SQLJSON  (Steven Schlansker <stevenschlansker@gmail.com>)
List pgsql-jdbc


Dave Cramer

On 26 June 2015 at 13:01, Steven Schlansker <stevenschlansker@gmail.com> wrote:

On Jun 26, 2015, at 7:57 AM, Dave Cramer <davecramer@gmail.com> wrote:

> I'm looking for comments on how to implement a SQLJSON type in JDBC.
>
> As there is no getSQLJSON in the resultset interface this could only be used in getObject.
>
> Notionally it would model itself after SQLXML. https://docs.oracle.com/javase/7/docs/api/index.html?java/sql/SQLXML.html

I used JSON extensively in one of my projects, but have never used SQLXML.  I'm having trouble understanding why the SQLXML interface adds any value to passing rs.getBinaryStream to your favorite JSON parser.  Especially since you would have to use getObject, I am not seeing how:

rs.getObject("field", SQLJSON.class).mapToType(MyType.class)

is simpler than:
jacksonObjectMapper.readValue(rs.getBinaryStream("field"), MyType.class)

which already works today as far as I understand.  Doubly so since nobody will agree on which JSON parsing library to use.

I'm sure I'm missing something?


I don't think you are; as you rightly pointed out now we would have to add a json parser to the driver, which I'm reluctant to do 

pgsql-jdbc by date:

Previous
From: Steven Schlansker
Date:
Subject: Re: SQLJSON
Next
From: Steven Schlansker
Date:
Subject: Re: SQLJSON