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

by lindsey.homenick , in category: Third Party Scripts , 5 months ago

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

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by filiberto , 5 months 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.

Related Threads:

How to extract a value from json in presto?
How to get a value out of my json using regex?
How to get latest 3 months records in presto sql?
How to create json type in entity in symfony?
How to extract json array in presto?
How to dump http "content-type: application/json;" in fastapi?