dchester / jsonpath

Query and manipulate JavaScript objects with JSONPath expressions. Robust JSONPath engine for Node.js.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

output of stringify function not compatible with query function

joelleortiz opened this issue · comments

When using stringify, the path expression output is not directly compatible for use in the query function to get data from objects.

stringify output: $.response.items["*"]["iso-1234"]
query input: $.response.items[*]['iso-1234']

stringify output: $.items["*"]["\"te\\st\""]
query input: $.items[*]['\"te\\st\"']

i suspect it's because of the JSON.stringify step for string literals:

value = JSON.stringify(component.expression.value)

Are the two functions (stringify and query) meant to be used together in this way? Or is there any other way to generate a path expression from an array of element paths that can be directly used to query data later?

Struggling with the same issue of [*] becoming ["*"].