Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将带有带引号的字符串的json插入Postgres_Json_Postgresql - Fatal编程技术网

将带有带引号的字符串的json插入Postgres

将带有带引号的字符串的json插入Postgres,json,postgresql,Json,Postgresql,我有一些JSON我正试图插入到Postgres数据库中,但我无法正确地转义引号,这是我的代码 insert into Product_Templates (product) values( '{ "template_id": "OSBSheet", "name":'Exterior Wall Using 2\"x4\"x96\" Studs, Double Top Plate' } 我得到一个错误: 无效命令\“x96 如何解决此问题?请参见JSON中的键和字符串值用双引号括起来。字符串中的引

我有一些JSON我正试图插入到Postgres数据库中,但我无法正确地转义引号,这是我的代码

insert into Product_Templates (product) values( '{
"template_id": "OSBSheet",
"name":'Exterior Wall Using 2\"x4\"x96\" Studs, Double Top Plate'
}

我得到一个错误: 无效命令\“x96

如何解决此问题?

请参见JSON中的键和字符串值用双引号括起来。字符串中的引号必须以“\”字符开头:

select
'{
    "template_id": "OSBSheet",
    "name": "Exterior Wall Using 2\"x4\"x96\" Studs, Double Top Plate"
}'::jsonb

                                              jsonb                                              
-------------------------------------------------------------------------------------------------
 {"name": "Exterior Wall Using 2\"x4\"x96\" Studs, Double Top Plate", "template_id": "OSBSheet"}
(1 row) 

我已经改变了,我仍然得到相同的错误,无效的命令\“X96谢谢,问题是上面的其他插入格式不正确