ford prefect
ford prefect

Reputation: 7388

Loading JSON from Postgres Column via jdbc

I have a postgres table that I am loading data out of for a java application. One of my columns is of type JSON. The problem is JDBC ResultSet does not have a loader for Json. Is my best bet to use resultSet.getString("COLUMN_NAME") or is there another option?

Upvotes: 5

Views: 7326

Answers (1)

Andreas
Andreas

Reputation: 159114

To read from SQL using ResultSet? No other option (unless it's huge and defined as a CLOB).

To get JSON? Yes. You parse the JSON string you retrieved with getString(), using JSON parser of your choice, e.g. see this article: Top 7 Open-Source JSON-Binding Providers Available Today

Summary:

Upvotes: 8

Related Questions