@@ -1504,12 +1504,12 @@ void Path::makePath(const JSONCPP_STRING& path, const InArgs& in) {
1504
1504
index = index * 10 + ArrayIndex (*current - ' 0' );
1505
1505
args_.push_back (index );
1506
1506
}
1507
- if (current == end || *current++ != ' ]' )
1507
+ if (current == end || *++current != ' ]' )
1508
1508
invalidPath (path, int (current - path.c_str ()));
1509
1509
} else if (*current == ' %' ) {
1510
1510
addPathInArg (path, in, itInArg, PathArgument::kindKey);
1511
1511
++current;
1512
- } else if (*current == ' .' ) {
1512
+ } else if (*current == ' .' || *current == ' ] ' ) {
1513
1513
++current;
1514
1514
} else {
1515
1515
const char * beginName = current;
@@ -1529,7 +1529,7 @@ void Path::addPathInArg(const JSONCPP_STRING& /*path*/,
1529
1529
} else if ((*itInArg)->kind_ != kind) {
1530
1530
// Error: bad argument type
1531
1531
} else {
1532
- args_.push_back (**itInArg);
1532
+ args_.push_back (**itInArg++ );
1533
1533
}
1534
1534
}
1535
1535
@@ -1544,16 +1544,19 @@ const Value& Path::resolve(const Value& root) const {
1544
1544
if (arg.kind_ == PathArgument::kindIndex) {
1545
1545
if (!node->isArray () || !node->isValidIndex (arg.index_ )) {
1546
1546
// Error: unable to resolve path (array value expected at position...
1547
+ return Value::null;
1547
1548
}
1548
1549
node = &((*node)[arg.index_ ]);
1549
1550
} else if (arg.kind_ == PathArgument::kindKey) {
1550
1551
if (!node->isObject ()) {
1551
1552
// Error: unable to resolve path (object value expected at position...)
1553
+ return Value::null;
1552
1554
}
1553
1555
node = &((*node)[arg.key_ ]);
1554
1556
if (node == &Value::nullSingleton ()) {
1555
1557
// Error: unable to resolve path (object has no member named '' at
1556
1558
// position...)
1559
+ return Value::null;
1557
1560
}
1558
1561
}
1559
1562
}
0 commit comments