I have a JSON which comes with single quote for one of the fields like below. A function with JSON as Input parameter is created and be called directly from the application. I would have used regexp_replace at least if it is read into the function.
for ex:
select '{
"phrase": "foo",
"phrase_1": "'bar'"
}' :: json
syntax error at or near "'"
}'"
LINE 3: "phrase_1": "'bar'"
The output of this is an error. so my actual problem is this json is directly read into my function.
create or replace function f_n(in json) -- it is failing to read here
returns text
---
---
end;
$$
so what is that I can do here to avoid such problem in postgresql?