I read it as the OP was using curl to get a response from the JSONPATH Expression Tester website that he’d linked, and the response had quotes in it. If that is not the case, then everything makes a LOT more sense. But potentially identifies a bug in the JSONPATH transform, which you’ve stated that you’ve also experience. I’ve never seen it reported or seen it first-hand, and is just another point layer of befuddlement I had with reading this thread.
This makes me think of something though. In a recent post, I commented on Smart Quotes being a source of potential problems, which I have seen in my own rules. If the input to JSONPATH has smart quotes around the value, they will be returned in the result. For example, this will log Test: smartKeyValue=[null], smartValue=[“OK“], nosmart=[OK], arrayIndex=[two]
. Maybe related. Maybe just an oddity.
rule "Test"
when
System started
then
val String json = '{“status1“:“OK“,"status2":“OK“,"status3":"OK","foo": ["one", "two", "three"]}'
val String smartKeyValue = transform("JSONPATH", "$.status1", json)
val String smartValue = transform("JSONPATH", "$.status2", json)
val String nosmart = transform("JSONPATH", "$.status3", json)
val String arrayIndex = transform("JSONPATH", "$.foo[1]", json)
logDebug("Rules", "Test: smartKeyValue=[{}], smartValue=[{}], nosmart=[{}], arrayIndex=[{}]",smartKeyValue,smartValue,nosmart,arrayIndex)
end
Yes, array indexing works. I used them a while ago parsing data from a Bloomsky weather station and one of their older APIs.