JGS
JGS

Reputation: 369

insert json data into text datatype of POSTGRES table column

I am trying to insert json data into text datatype of postgres table.

For example, table1 is having columns as:

id | name | occupation | skills 
--------------------------------------------------------
1  | John | engineer   | {"java":"true","oracle":"true"} 
---------------------------------------------------------
2  | mary | engineer   | {".net":"true","mysql":"true"}

Here in the above table skills are of type text and we are inserting json data in it. How can I insert json data into text datatype of postgres table?

Upvotes: 0

Views: 3536

Answers (1)

Satendra
Satendra

Reputation: 6865

Convert your json to string, then try to save

"{\"java\":\"true\",\"oracle\":\"true\"}"

If you are inserting json data directly to postgres db, try converting json to string from online converter

Upvotes: 3

Related Questions