Hi Team
We have a requirement where we want to filter data in dashboard and as a datasource we’re using JSON API, in filter we want to provide multi-value filter support and based on that we want to filter data of our JSON API.
API response {
“items” : [
“name” :“test”,
“arr”:[
“a”:1,
“b”:2
]
]
}
Here i want to use name in dashboard filter and it can be multiselect and based on that i want to filter my json data which i am visualising in table view.
as here we need “IN” operator support , from documentation we didnt have any support .
Thanks
Please post a valid json that has been validated for example via https://jsonlint.com/
{
"items": [{
"name": "test",
"arr": [{
"a": 1,
"b": 2
}]
}, {
"name": "test1",
"arr": [{
"a": 2,
"b": 3
}]
}]
}
@yosiasz added here
1 Like
Recommend using infinity plugin
parse-json
| scope "items"
| jsonata "* [name in [${test:singlequote}]][]"
@yosiasz , can we add scope on “arr” field and put jsonata filter on name?
@subodh2711 - I think you need mv-expand
operator. More details https://yesoreyeram.github.io/grafana-infinity-datasource/wiki/uql/
parse-json
| scope "items"
| mv-expand "arrItem"="arr"
| jsonata "* [name in [${test:singlequote}]][]"
1 Like
@yesoreyeram , its coming as in json format can we split and show and explicitly. and what about if we have an array inside arr again can we define scope on nested array and go inside that.
adding
| project "name", "a"="arrItem.a", "b"="arrItem.b"
at the end of the UQL query will help.
1 Like
Thanks , i tried it helps