How to get the type of a json value in presto?

by lindsey.homenick , in category: Third Party Scripts , 10 days ago

How to get the type of a json value in presto?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by filiberto , 9 days ago

@lindsey.homenick 

You can use the typeof function in Presto to get the type of a JSON value. Here is an example of how you can do this:

1
SELECT typeof(json_parse('{"key": "value"}')->'key');


In this example, json_parse is used to parse the JSON string into a JSON object, and typeof is used to get the type of the value associated with the key 'key'. The result will be the type of the JSON value.


Note that json_parse function is used to parse a JSON string into a JSON object, so make sure to provide a valid JSON string as input.