Skip to content

Commit f72f379

Browse files
authored
v0.9.13 - no comments
Fixed an issue when 0 is specified as a string in reference to an array would trigger a leading zero exception
1 parent b37c7de commit f72f379

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

jsonpath.no_comment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// JSONPath 0.9.12 (no comments) - XPath for JSON
1+
// JSONPath 0.9.13 (no comments) - XPath for JSON
22
// Copyright (c) 2020 Joel Bruner (https://github.com/brunerd)
33
// Copyright (c) 2020 "jpaquit" (https://github.com/jpaquit)
44
// Copyright (c) 2007 Stefan Goessner (goessner.net)
@@ -256,7 +256,7 @@ function jsonPath(obj, expr, arg) {
256256
var x = expr.slice()
257257
var loc = x.shift();
258258

259-
if(val !== null && Array.isArray(val) && loc.constructor === String && loc.match(/^0/)){
259+
if(val !== null && Array.isArray(val) && loc.constructor === String && loc.match(/^0/) && loc !== "0"){
260260
throw new Error("Property name '"+ loc +"' is a string with leading zeros and target is an array!")
261261
}
262262
else if(val !== null && val.constructor === Object && loc.constructor === Number){

0 commit comments

Comments
 (0)