Searching indexed array
Closed this issue · 1 comments
I wonder if you are able to help, tell me whether this should be possible or not with JSONPath. I'm using I'm using your package in conjunction with codeception for acceptance test.
Essentially what I want to do is search a json result to see whether an email has been sent with a 'Subject': 'Your password reset'
{
"total":1,
"count":1,
"start":0,
"items":[
{
"Subject": "Your password reset request"
}
]
}
Now in the above example we could easily achieve this by $.items..[?(@.Subject = "Your password reset request")]
. JSON path would pick up:
[
{
"Subject":"Your password reset request"
}
]
However the json I receive back the Subject matter is not a string its an array:
{
"total":1,
"count":1,
"start":0,
"items":[
{
"Subject": ["Your password reset request"]
}
]
}
Is there anyway JSONPath is able to achieve this?
Hi Paul,
Yeah I've been testing and trying a few experiments to see if I can achieve what you're looking for but I don't think it's possible in the current state... seems like it's just a weakness of the syntax / current spec.
In theory, this would be the best syntax:
$.items.*.[?(@.Subject.0 = "Your password reset request")]
To achieve that the library would need to get into the territory of recursive parsing and I'm not totally ready to get into that ;)