I'm trying to cast JSON object from table column to varchar with Trino I tried with these docs here but every time throws an error. https://trino.io/docs/current/functions/json.html If someone can post an example how I can make that it will be great.
1 Answer
Use json_format
/json_parse
to handle json object conversions instead of casting:
select json_parse('{"property": 1}') objstring_to_json, json_format(json '{"property": 2}') jsonobj_to_string
Output:
objstring_to_json | jsonobj_to_string |
---|---|
{"property":1} | {"property":2} |
-
I had to do the same in AWS Athena, and the
json_format
function works there as well. @Guru thanks!– HagaiAJan 3 at 15:28