WorkMaze / JUST.net

JUST - JSON Under Simple Transformation (XSLT equivalent for JSON).
MIT License
174 stars 54 forks source link

(4.1+) JsonPath expression is unexpectedly un-escaped #185

Open verotoad opened 3 years ago

verotoad commented 3 years ago

Looping on an array filtered by JsonPath query, double slash pattern are unexpectedly un-escaped, returning an invalid result. This issue has been introduced since version 4.1 due to PR #137

JSON input

{ "arrayobjects": [ { "id": "http://sampleurl.invalid", "value": "myvalue" } ] }

Transformation

{ "result": { "#loop($.arrayobjects[?(@id == 'http://sampleurl.invalid')])": { "id": "#currentvalueatpath($.id)", "value": "#currentvalueatpath($.value)" } } }

Expected result

{ "result": [{ "id": "http://sampleurl.invalid", "value": "myvalue" }] }

Actual result

null

Courela commented 3 years ago

Slash is the escape character, it is assumed that the double slash after 'http:' is an escaped slash, turning it into only one slash. For that expression to work, 4 slashes are needed: http:////sampleurl.invalid