Re: best way to convert JSONB object from result

From: Mikko Tiihonen <Mikko(dot)Tiihonen(at)nitorcreations(dot)com>
To: Tom Smith <tomsmith1989sk(at)gmail(dot)com>, "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: best way to convert JSONB object from result
Date: 2015-08-20 07:16:45
Message-ID: DB3PR07MB048980BF11D2C917C827BD48F2660@DB3PR07MB0489.eurprd07.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

You are using the most efficient way. I tried to look into converting the jsonb value directly to some json parser in the jdbc driver, but it turned out the the server always sends jsonb as a serialized string instead of the faster-to-parse internal jsonb storage format.

-Mikko

________________________________
From: pgsql-jdbc-owner(at)postgresql(dot)org <pgsql-jdbc-owner(at)postgresql(dot)org> on behalf of Tom Smith <tomsmith1989sk(at)gmail(dot)com>
Sent: 19 August 2015 22:20
To: pgsql-jdbc(at)postgresql(dot)org
Subject: [JDBC] best way to convert JSONB object from result

Hi:

I am trying to convert to a Java or Map object
from resultset with a jsonb column.
Currently, I am using

String jsonString = resultSet.getString("jsonb_column_name")

then I convert from jsonString to a Map<String,Object> or a Java class object.

This is obviously inefficient. What would be most efficient (not too complicated)

Thanks in Advance

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message rcohen 2015-08-21 17:03:47 Re: sql type reported for enum
Previous Message Amit Kapila 2015-08-20 03:06:31 Re: Proposal: Implement failover on libpq connect level.