Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z8tPU-0003c0-FC for pgsql-jdbc@arkaria.postgresql.org; Sat, 27 Jun 2015 16:56:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Z8tPT-0008F4-Ub for pgsql-jdbc@arkaria.postgresql.org; Sat, 27 Jun 2015 16:56:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Z8tOn-0007bR-Sp for pgsql-jdbc@postgresql.org; Sat, 27 Jun 2015 16:56:13 +0000 Received: from mail-wi0-f179.google.com ([209.85.212.179]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Z8tOl-0001JY-CZ for pgsql-jdbc@postgresql.org; Sat, 27 Jun 2015 16:56:13 +0000 Received: by wiwl6 with SMTP id l6so67805443wiw.0 for ; Sat, 27 Jun 2015 09:56:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=YpV8XSe5bzjWxG0AbtOUy2kBF+x0cPzpPVoMdvIDJTM=; b=ht1XcaVfm+SpmQ/7U9gpJfz3eDKO6Gde4B9CZ9OMXPyMb6+5b8vJhYEM2nIOKuCD2Q jUmWikDNmR/oU0Auut4euHTxlUB1bx1z30baLySwOsZyV+MSIsKfY8ZfX2JHuGDpPBeg i2/6yYXIYZr7A+pKgGJG/XPGt4vdxtOPlD0Wed/WtEBSuZoOq98Ao9PLdcCPl/fujAzM o2vXbga3GePfYKNPeFWtenJhsFyZX1qpcHN24QSMmMbGOVcmJhgh/lUQuX35363d0tmj F8ZJsRdKeo1Nt+mNtoY/1MwB9hUJQpnrCyydc5T5EhcY8rmjROVmE1S2kgO8PqcouRKL R32w== X-Gm-Message-State: ALoCoQmIIawe2iprEYCBMviN/NB/FxS2o/8Jq73hFuM7JuXZ04AoVBcz5N8ikafsnYaRsQXwZLwl X-Received: by 10.180.100.197 with SMTP id fa5mr7172331wib.65.1435424169856; Sat, 27 Jun 2015 09:56:09 -0700 (PDT) Received: from [192.168.1.41] (94.red-80-29-123.adsl.static.ccgg.telefonica.net. [80.29.123.94]) by mx.google.com with ESMTPSA id n10sm3686241wiz.19.2015.06.27.09.56.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 27 Jun 2015 09:56:08 -0700 (PDT) Message-ID: <558ED5A6.4070500@8Kdata.com> Date: Sat, 27 Jun 2015 18:56:06 +0200 From: =?ISO-8859-1?Q?=C1lvaro_Hern=E1ndez_Tortosa?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: SQLJSON References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -0.3 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org On 26/06/15 19:29, Steven Schlansker wrote: > On Jun 26, 2015, at 10:23 AM, Dave Cramer wrote: > >> On 26 June 2015 at 13:01, Steven Schlansker wrote: >> >> On Jun 26, 2015, at 7:57 AM, Dave Cramer 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 >> > If this feature is developed, I think the JSON parser should be pluggable and optional if possible. Then users that do not want it do not need to drag in a large dependency. > > That said, without a more convincing use case or a compelling API that we could easily add, I don't see this interface being "worth its weight" as an addition. > > > Hi List. I always try to think more from the user perspective than from the developer one. This is also going to be the case. Having JSON support in the PostgreSQL JDBC driver is a *must*. jsonb was 9.4's next-big-thing-since-sliced-bread jet there's no support in one of the most used PostgreSQL drivers. No blame here (at all), just trying to support my point here. I don't see the advantage of using SQLJSON, although I wouldn't argue against. What I clearly believe is that at the end of the day you should be able to easily return a javax.json.JsonObject from a ResultSet. Being a JavaEE standard and a JSR, I believe it's the best (and obvious) choice. Regarding pluggability, JSR353's SPI mechanism is good, but asking the user to provide a further dependency "just for reading JSON" seems again to me not good from the user perspective. I'd ideally expect json to be supported as-is, as with any other datatype. Having the SPI we could choose whatever implementation we want. Is that enlarging the driver's size? So what? Users want easy-of-use, not driver size. And there are many mechanisms to reduce size for unused classes. If any, my 2 cents are: let's add JSON, let's take JSR353 as an API for it and let's make it as easy as possible for final users to use it. Regards, Álvaro -- Álvaro Hernández Tortosa ----------- 8Kdata -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc