grafana-json-datasource
grafana-json-datasource copied to clipboard
JSONPath and JSONata
Hi,
Thank you for your hard work, this plugin works pretty well now.
But I found something does not work well in query with a variable in both JSONpath and JSONata Here is my problem:
- Using JSONPath:
$.DevInfo[?(@.Date=="$Date")].Projects[?(@.ProjectName =~ /.*Test/ )] --> not work with regex /.*Test/
- Using JSONata
$.DevInfo[?(@.Date=="$Date")].Projects[*].ProjectName --> work well
DevInfo[Date=$Date)].Projects.ProjectName --> not work
Hope you could help me. Thank you in advance.
I'm not sure I understand the problem. Could you provide an example JSON document and a query that demonstrates the issue, so that I can test it myself?
I've also seen oddities with the JSONPath implimentation, two I've run into:
- If root JSON object starts with
[, filters don't work as expected - the
infilter doesn't seem to be working
For the later, here's an example: object:
{
"store" : {
"book" : [
{
"category" : "reference",
"author" : "Nigel Rees",
"title" : "Sayings of the Century",
"price" : 8.95
},
{
"category" : "fiction",
"author" : "Evelyn Waugh",
"title" : "Sword of Honour",
"price" : 12.99
},
{
"category" : "fiction",
"author" : "Herman Melville",
"title" : "Moby Dick",
"isbn" : "0-553-21311-3",
"price" : 8.99
},
{
"category" : "fiction",
"author" : "J. R. R. Tolkien",
"title" : "The Lord of the Rings",
"isbn" : "0-395-19395-8",
"price" : 22.99
}
],
"bicycle" : {
"color" : "red",
"price" : 19.95
}
},
"expensive" : 10
}
JSONPath:
$.store.book[?(@.category in ['fiction', 'non-fiction'])].author
Expected result:
[
"Evelyn Waugh",
"Herman Melville",
"J. R. R. Tolkien"
]
@u2mejc For your query, the following works for me:
store.book[category in ['fiction', 'non-fiction']].author
For me this does not work. is there a fix for this issue