mirror of
https://github.com/tristanpenman/valijson.git
synced 2024-12-12 10:13:51 +01:00
Fix array indexing bug in JSON Pointer implementation
This commit is contained in:
parent
c43c8568f5
commit
b4c2dbd875
@ -78,7 +78,8 @@ inline AdapterType resolveJsonPointer(
|
||||
} else if (node.isArray()) {
|
||||
try {
|
||||
// Fragment must be non-negative integer
|
||||
const uint64_t index = boost::lexical_cast<uint64_t>(jsonPointer);
|
||||
const uint64_t index = boost::lexical_cast<uint64_t>(
|
||||
referenceToken);
|
||||
typedef typename AdapterType::Array Array;
|
||||
typename Array::const_iterator itr = node.asArray().begin();
|
||||
|
||||
|
@ -104,6 +104,21 @@ std::vector<boost::shared_ptr<JsonPointerTestCase> >
|
||||
testCase->expectedValue = NULL;
|
||||
testCases.push_back(testCase);
|
||||
|
||||
rapidjson::Value testArray;
|
||||
testArray.SetArray();
|
||||
testArray.PushBack("test0", allocator);
|
||||
testArray.PushBack("test1", allocator);
|
||||
testArray.PushBack("test2", allocator);
|
||||
|
||||
testCase = boost::make_shared<JsonPointerTestCase>(
|
||||
"Resolve '/test/1' in object containing one member containing "
|
||||
"an array with 3 elements");
|
||||
testCase->value.SetObject();
|
||||
testCase->value.AddMember("test", testArray, allocator);
|
||||
testCase->jsonPointer = "/test/1";
|
||||
testCase->expectedValue = &testCase->value.FindMember("test")->value[1];
|
||||
testCases.push_back(testCase);
|
||||
|
||||
return testCases;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user