From: | Dave Cramer <pg(at)fastcrypt(dot)com> |
---|---|
To: | Alexander Farber <alexander(dot)farber(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How to retrieve jsonb column through JDBC |
Date: | 2016-08-28 01:16:58 |
Message-ID: | CADK3HH+sJWspWb=RGEGGeK0oH+inULt70-AOFWXxixn0EdrSdg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Unfortunately JSONB is output in text. So this is the way it is done.
Dave Cramer
davec(at)postgresintl(dot)com
www.postgresintl.com
On 27 August 2016 at 06:39, Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
wrote:
> Hello,
>
> what do you use to retrieve a jsonb column using JDBC?
>
> I have tried
>
> Object last_tiles = rs.getObject("last_tiles");
>
> and the resulting Object seems to be a String.
>
> Then I have called (using Jetty JSON class here):
>
> Object last_tiles = JSON.parse(rs.getString("last_tiles"));
>
> And it seems to work ok... but I am still curious, what is the recommended
> (or maybe planned for future) way for retrieving jsonb data in Java.
>
> Also
>
> List last_tiles = (List) JSON.parse(rs.getString("last_tiles"));
>
> has not work for me even though the string is:
>
> [{"col": 7, "row": 8, "value": 1, "letter": "A"}, {"col": 7, "row": 7,
> "value": 2, "letter": "B"}, {"col": 7, "row": 9, "value": 2, "letter": "C"}]
>
> but it is probably the problem of the Jetty class I am using and not of
> JDBC...
>
> Regards
> Alex
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Edson Analista | 2016-08-28 02:45:50 | Error Upgrade PostgreSQL 9.4 to 9.5 in Debian |
Previous Message | Alexander Farber | 2016-08-27 10:39:37 | How to retrieve jsonb column through JDBC |