Skip to main content

How to insert JSON Column Value?

DB2Rest can save JSON data in JSON/JSONB column of a PostgreSQL database table. It can also save in MySQL columns of data type JSON. In order to test, create the tables as shown below.

PostgreSQL

CREATE TABLE products (
id serial4 NOT NULL,
"name" varchar(100),
extra_info jsonb NULL,
CONSTRAINT products_pkey PRIMARY KEY (id)
);

MySQL

CREATE TABLE `products` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`extra_info` json DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
);

Insert Request


curl --request POST \
--url http://localhost:8080/v1/rdbms/pgdb/products \
--header 'Content-Type: application/json' \
--header 'User-Agent: insomnia/9.2.0' \
--data '{
"name": "Big egg",
"extra_info": { "expiry_date": "2025-12-31", "exportable": true }
}'

HTTP Response

TODO