|
1 | | -// JSONPath 0.9.18 - XPath for JSON |
| 1 | +// JSONPath 0.9.19 - XPath for JSON |
2 | 2 | // Copyright (c) 2021 Joel Bruner (https://github.com/brunerd) |
3 | 3 | // Copyright (c) 2020 "jpaquit" (https://github.com/jpaquit) |
4 | 4 | // Copyright (c) 2007 Stefan Goessner (goessner.net) |
@@ -563,15 +563,16 @@ function jsonPath(obj, expr, arg) { |
563 | 563 | } |
564 | 564 | } |
565 | 565 | //else we are either a number or string |
566 | | - //if val is truthy and loc exists, keep tracing |
567 | | - else if (val && val.constructor !== String && val[loc] !== undefined) { |
| 566 | + //if val is truthy, not a string, val[loc] exists and is not a function (i.e. Object.values()), keep tracing |
| 567 | + else if (val && val.constructor !== String && val[loc] !== undefined && typeof val[loc] !== "function") { |
568 | 568 | var tpath = path.slice() |
569 | 569 | //if this is an array, store loc as Number so it is NOT quoted in PATH or PATH_DOTTED output |
570 | 570 | tpath.push(Array.isArray(val) ? Number(loc) : loc) |
571 | 571 | P.trace(x, val[loc], tpath); |
572 | 572 | } |
573 | 573 | } |
574 | 574 | //else no expr left, just store the results along with it's path |
| 575 | + //for some reason a key with the name "values" will create a function as a result?! Ignore it. |
575 | 576 | else { |
576 | 577 | P.store(path, val); |
577 | 578 | } |
@@ -632,10 +633,6 @@ function jsonPath(obj, expr, arg) { |
632 | 633 |
|
633 | 634 | var tx = x.slice() |
634 | 635 |
|
635 | | - //WOW this should not be needed, parens have no effect leave them if present |
636 | | - //if this is a () expression, strip the outer parens |
637 | | - //if ((/^\(.*?\)$/).test(x)) { tx = tx.replace((/^\((.*?)\)$/),"$1") } |
638 | | - |
639 | 636 | //remove all all data between "" '' and //, split by semi-colon |
640 | 637 | //remove all spaces before ( and collapse multiple spaces down to a single space |
641 | 638 | var forbiddenInvocations=tx.split('').reverse().join('') |
|
0 commit comments