将json数据插入POSTGRES表列的text数据类型

时间:2017-09-22 11:48:30

标签: json postgresql

我正在尝试将json数据插入postgres表的text数据类型。

例如,table1的列为:

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

在上面的表中,技能是文本类型,我们在其中插入json数据。 如何将json数据插入postgres表的text数据类型?

1 个答案:

答案 0 :(得分:2)

将您的json转换为字符串,然后尝试保存

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

如果要将json数据直接插入postgres db,请尝试将json转换为online converter

中的字符串