JSONPath-Plus / JSONPath

A fork of JSONPath from http://goessner.net/articles/JsonPath/
Other
964 stars 169 forks source link

Sandbox parameters don't work #44

Closed mglazer-cengage closed 8 years ago

mglazer-cengage commented 9 years ago

I don't see any tests for using sandbox parameters and they don't seem to work

json = {"books":[{"title":"kids", "author":"adams"},{"title":"action", "author":"johns"}]}

path = '$..books[?(@.title==@.param)]'

JSONPath({json:json, path : path, sandbox : {param:'kids'}} )

This JSBIN demonstrates this with two test:

http://jsbin.com/cupehuyayo/edit

The first test above is with the param second is with a string

Any help would be appreciated, thank you.

brettz9 commented 8 years ago

In your case, it should be:

var ext = param ? 'param' : '"kids"';

I've also added a test to master.

Feel free to comment further, but closing as should be addressed now.