How to store JSON object into PostgreSQL using JSONB data type inside table and PostgreSQL JDBC driver How to store JSON object into PostgreSQL using JSONB data type inside table and PostgreSQL JDBC driver json json

How to store JSON object into PostgreSQL using JSONB data type inside table and PostgreSQL JDBC driver


We can use PGObject and Jackson Object mapper to save the json in Postgres

val person=PGobject()person.type="jsonb"person.value=ObjectMapper.writeValueAsString("{"fname":"john","lname":"doe"}")

now person object can be passed to JDBC driver for storing data as jsonb