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?
1 Answer
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:
3 Comments
ford prefect
Thanks. Couldn't find another place where it was supported... Seemed like the kind of thing that would be implemented given it is a supported datatype in postgres
Andreas
But it's not a supported datatype in Java or JDBC.
ford prefect
Came back across this now many moons later and realized the difference. Thanks.