I'm working on a postgresql base that was powered by a MongoDB. The intake was all in JSON, it happens that some fields came as STRING and I am unable to retrieve the value.
For example, The field and value are as follows:
"Info":
"{\" categoryName \ ": \" Sale \ ", \" seller \ ": \" Uber \ ", \" categoryId \ ": \" 022 \ ", \" Payment \ ": false}"
Already tried using REPLACE, SPLIT_PART, CONVERTER STRING PRA JSON but nothing worked.
SELECT case
when json->'payload'->'com'->0->>'Info' is null
then ''
else json->'payload'->'com'->0->>'Info'::json
end Test
FROM tableJson
I need to turn this line into JSON:
"Info": {
"categoryName": "Sale",
"seller": "Uber",
"categoryId": "022",
"Payment": false "}