-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JsonPath remove [ ] #484
Comments
Hi, the result of your querypath [
{
"timestamp": "20180719T11:45:24Z",
"type": "S1",
"mac": "AC233FA03DB6",
"bleName": "",
"rssi": -53,
"battery": 100,
"temperature": 20.18,
"humidity": 63.02
},
{
"timestamp": "someothertime",
"type": "S2",
"mac": "AC233FA03DB6",
"bleName": "",
"rssi": -54,
"battery": 50,
"temperature": 12,
"humidity": 80.02
}
] Then the result is [
20.18,
12.0
] If you would like to only get one single value, without the list, you have to use a distinct path. For example the corresponding normalised path {
"AC233FA03DB6": {
"timestamp": "20180719T11:45:24Z",
"type": "S1",
"bleName": "",
"rssi": -53,
"battery": 100,
"temperature": 20.18,
"humidity": 63.02
},
"ANOTHERMAC": {
"timestamp": "someothertime",
"type": "S2",
"bleName": "",
"rssi": -54,
"battery": 50,
"temperature": 12,
"humidity": 80.02
}
} Then the distinct path |
Almost solved my problem. I will explain to you, I have several sensors and two temperature sensors, when the Json package arrives it sometimes sends in random order, that way I would have to use the mac as a filter because it contains more sensors and the position always changes. This is my Json package
if I use |
Why don't you just use the first value of the returned array? |
What I want you to understand is that array information can vary, temperature and humidity may come in the [0], [2] or [5] for example, which implies that I'm using an application called mqtt dashboard, when I create a dashboard I put as for example |
I saw now the same problem in other topic |
how to remove [] in my result in JsonPath, I saw in other topics using id, but I not have ID. This is code I use:
and this is the filter
$..[?(@.mac=='AC233FA03DB6' )].temperature
I use this site for test my examples: (http://jsonpath.herokuapp.com/?path=$..book[2:])
The text was updated successfully, but these errors were encountered: