1

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 1

5

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}
1
  • I had to do the same in AWS Athena, and the json_format function works there as well. @Guru thanks!
    – HagaiA
    Jan 3 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.