huginn: JSONPath parser is not parsing ?(@) conditions correctly
Hi.
Here is an interesting bug… I’m trying to create a reddit agent which lists the last 25 submits, but only those who are voted above 0. For this, I’m using this simple JSON from reddit: https://www.reddit.com/r/golang/new.json?sort=new
I can’t use XML because reddit’s XML api doesn’t have ups in it. Which is a bit stupid. But that’s how things are.
I’m trying to use this as an agent definition:
{
"expected_update_period_in_days": 2,
"url": "https://www.reddit.com/r/golang/new.json?sort=new",
"type": "json",
"mode": "on_change",
"extract": {
"title": {
"path": "$.data.children[*].data[?(@.ups > 0)].title"
}
}
}
Which, according to JSONPath definition, should work. However, it doesn’t return anything. But get this… Neither do many of the online parsers, except for this one: http://jsonpath.herokuapp.com/?path=$.store.book[?(@.price < 10)] Which turns out to be a correct way of implementing JSONPath. It’s implementation is located here: https://github.com/jayway/JsonPath
So… can we switch out the parser, or at least fix it so it interprets conditions correctly?
Thanks!
Note: Eval is enabled. I’m not getting anything back, not, getting an evaluation error.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (15 by maintainers)
Commits related to this issue
- Updated jsonpath to jsonpathv2 to support scripting and to switch to a more up to date version of the gem. Issue #1591. (#1596) — committed to huginn/huginn by Skarlso 8 years ago
@Skarlso That sounds great! I think it would be a good idea to keep the old
JsonPathclass name, that would allow us to only switch the new gem without having to change any code. Do you see any downsides in keeping the old namespace?