Azure/usql

How to extract nested properties using JSONTuple Function.

Opened this issue · 2 comments

Below is the sample extract json,

{
"AReference": "XXXXXXXXXXXX",
"Id": 111111111,
"items": [
{
"vId": 22222222,
"rReason": {
"AB": 1,
"XY": "ABC XYZ"
}
}
],
"time": "2017-12-28T13:51:18.6679191Z"
}

Hi Gaurav

Have you tried to look at the sample scripts here on GitHub?

Thanks
Michael

Hi Mike

I looked into the solution given in GitHub and applied various techniques to read nested properties. Examples like,

JsonTuple(json, "id", "name") -> field names MAP{ {id, 1 }, {name, Ed } }
JsonTuple(json, "$.address.zip") -> nested fields MAP{ {address.zip, 98052} }

These are the same examples being showcased as to how you can read specific and nested properties but it doesn't work. If you could share a sample code using JsonTuple() to read nested properties from and array object, it would help me better understand the logic within.

For now I've used MultiLevelJsonExtractor() to achieve the same and it's working for me.

Thanks
Gaurav