I have a JSON object coming in that has single quotes, e.g. {'key': 'value'}
and I want to store this JSON object in a varchar
column.
Attempting to insert the JSON object converted to a string throws an error that the line is not closed properly due to the single quotes.
CodePudding user response:
JSON standard requires names in name-value pairs to be strings which according to the same standard require double quotes:
A string is a sequence of zero or more Unicode characters, wrapped in double quotes
So according to the standard this is not a valid json (though quite a lot of parsers relax this requirement and allow single quotes to enclose the names, but not the Trino one), so you need to replace single quotes with double ones.