Skip to content

Commit 782a947

Browse files
authored
Update jsonpath.js
1 parent 0c83afb commit 782a947

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

jsonpath.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// JSONPath 0.9.18 - XPath for JSON
1+
// JSONPath 0.9.19 - XPath for JSON
22
// Copyright (c) 2021 Joel Bruner (https://github.com/brunerd)
33
// Copyright (c) 2020 "jpaquit" (https://github.com/jpaquit)
44
// Copyright (c) 2007 Stefan Goessner (goessner.net)
@@ -563,15 +563,16 @@ function jsonPath(obj, expr, arg) {
563563
}
564564
}
565565
//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") {
568568
var tpath = path.slice()
569569
//if this is an array, store loc as Number so it is NOT quoted in PATH or PATH_DOTTED output
570570
tpath.push(Array.isArray(val) ? Number(loc) : loc)
571571
P.trace(x, val[loc], tpath);
572572
}
573573
}
574574
//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.
575576
else {
576577
P.store(path, val);
577578
}
@@ -632,10 +633,6 @@ function jsonPath(obj, expr, arg) {
632633

633634
var tx = x.slice()
634635

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-
639636
//remove all all data between "" '' and //, split by semi-colon
640637
//remove all spaces before ( and collapse multiple spaces down to a single space
641638
var forbiddenInvocations=tx.split('').reverse().join('')

0 commit comments

Comments
 (0)