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.
Asked
Active
Viewed 3,648 times
1 Answers
7
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} |

Guru Stron
- 102,774
- 10
- 95
- 132
-
2I had to do the same in AWS Athena, and the `json_format` function works there as well. @Guru thanks! – HagaiA Jan 03 '23 at 15:28