Home > OS >  How to escape / handle with double qoutes within values of a json object
How to escape / handle with double qoutes within values of a json object

Time:06-21

I have a JSON file, unfortunatelly contains one if the value for formatting additional double quotes. So i try to read the file first as a text object.

How can i escape the double quotes within the values:

create table test_txt (exif text);
insert into test_txt values ('{"id": "1234", "name": "this is "my" Name", "adress": "12345 City "of" test"}');
Select exif::json from test_txt;

If i want to change the text object in a json object.

I get the file with curl from a url. Is there a difference between curl in cmd console

curl "url" -o c:\tmp\test.json

and

copy tablename ("columnname") from program 'curl "url"' in postgres

CodePudding user response:

I think this might help you:

How can I escape a double quote inside double quotes?

Basically use the \" to add a cuote inside a cuotes.

CodePudding user response:

select '{"name": "this is \"my\" Name"}' ::json;
  • Related