How to extract values from nested json objects using JSON Extractor
See original GitHub issueI have a json file that contains a few properties, say,
{
"A": [
{
"property1": "value 1",
},
{
"A1": [
{
"property2": "value 2",
"property3": "value 3"
}
],
"property4": "value 4"
}
],
"B": {
"custom": {
"B1": [
{
"property5": "value 5",
"property6": "value 6",
"property7": "value 7"
}
],
"metrics": [ ]
},
"property8": { }
}
}
Few of them are nested. How to extract the nested property values using JSON extractor. For example, I want to extract the values of properties 5,6,7.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
How to extract nested elements in JSON response using ...
I would like to extract an element based on a condition inside a nested JSON response. Using the widely searched example below, ...
Read more >How to unnest / extract nested JSON data in MySQL 8.0
For simple JSON strings like these, we just need to use the JSON_EXTRACT() function.
Read more >Extract data from nested json array / meta_data
Hi guys,. i have got the below Json result, and i want to extract order_no and deliverydate for each order using power automate....
Read more >How to extract nested JSON fields and array from S...
I'm trying to extract some information from nested JSON data stored in Splunk. Here's a simplified and anonymized example of the type of ......
Read more >Extract Nested Data From Complex JSON
Extract Nested Data From Complex JSON. Never manually walk through complex JSON objects again by using this function. Todd Birchard · Python.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, you can use the JsonTuple function to get the values, the code snippet to extract the properties 5,6 and 7 is done as follows
@jsonnodes = SELECT JsonApp.JsonFunctions.JsonTuple(jsonstring, “$…property5”, “$…property6”, “$…property7”) AS json_map FROM @json;
@nodes_exploded = SELECT name, node_value FROM @jsonnodes CROSS APPLY EXPLODE(json_map) AS T(name, node_value);
The snippet above will give you an output as follows “custom.B1[0].property5”, “value 5” “custom.B1[0].property6” , “value 6” “custom.B1[0].property7”, “value 7”
Please let me know if this helps and if you have any further questions.
jsonstring is the string you extracted out of the JSON using the JSONExtractor. I have also published code that parses Json on the github site - please do take a look at https://github.com/Azure/usql/blob/master/Examples/JsonSample/JsonSample/NestedJsonParsing.usql that will give the full script that starts with extracting content from a JSON file and manipulating the data. Please let me know if you have any questions.