I am trying to extract specific field from json by filtering data based on it's value instead of Index.
For example my json looks like below
"AllData": [
{
"ID": "1",
"Value": "Value1"
},
{
"ID": "2",
"Value": "Value2"
},
{
"ID": "3",
"Value": "Value3"
},
{
"ID": "4",
"Value": "Value4"
},
{
"ID": "5",
"Value": "Value5"
}
]
}
I need to project section (id and value) where value = valueX. But valueX may not always at index X it can be at any other index also. So while projecting I can not use Index. I need to project based on value. I can use contains operator in my where clause which helps to filter the arrays (list of AllData array) as shown below
MyDataSet
| where parse_json(MyJson) contains("Value5")
| project MyJson[5].ID, MyJson[5].Value // this may give wrong result because Value5 can be at some other index
Any Suggestions will be helpful.