mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-06-28 07:11:40 +00:00
build wasm
This commit is contained in:
@ -935,4 +935,70 @@ describe('ISSUE test', () => {
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('Failure to match "$..[\'$ref\']", "$..[\'ref\']", but succeeds on "$..ref" #43', (done) => {
|
||||
|
||||
function select(json, expected, paths) {
|
||||
for (var i = 0 ; i < paths.length ; i++) {
|
||||
let result = jsonpath.select(json, paths[i]);
|
||||
if (JSON.stringify(result) !== JSON.stringify(expected)) {
|
||||
throw Error("Error: " + paths[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let json = {
|
||||
"Junk1": "This is a test to illustrate use of '$' in the attr for the expression $..['$ref'] ",
|
||||
"$ref": "Match Root",
|
||||
"Subset1":[
|
||||
{"Junk2": "Data...",
|
||||
"$ref": "Match Subset1"
|
||||
}
|
||||
],
|
||||
"hierachy1":{
|
||||
"hierachy2.1":{
|
||||
"hierachy2.1.1":{ "$ref":"Match 2.1.1"},
|
||||
"hierachy2.1.2":{ "ref":"Match 2.1.2"},
|
||||
"hierachy2.1.3":{ "ref":"No Match 2.1.3"},
|
||||
"hierachy2.1.4":{ "$ref":"Match 2.1.4"},
|
||||
"hierachy2.1.5":{ "ref":"No Match 2.1.5"}
|
||||
},
|
||||
"hierachy2.2":{
|
||||
"hierachy2.2.1":{ "ref":"No Match 2.2.1"},
|
||||
"hierachy2.2.2":{ "$ref":"Match 2.2.2"},
|
||||
"hierachy2.2.3":{ "ref":"No Match 2.2.3"},
|
||||
"hierachy2.2.4":{ "ref":"No Match 2.2.5"},
|
||||
"hierachy2.2.5":{ "$ref":"Match 2.2.5"}
|
||||
},
|
||||
"hierachy2.3":{
|
||||
"hierachy2.3.1":{ "ref":"No Match 2.3.1"},
|
||||
"hierachy2.3.2":{ "ref":"No Match 2.3.2"},
|
||||
"hierachy2.3.3":{ "ref":"No Match 2.3.3"},
|
||||
"hierachy2.3.4":{ "ref":"No Match 2.3.4"},
|
||||
"hierachy2.3.5":{ "ref":"No Match 2.3.5"},
|
||||
"hierachy2.3.6":{
|
||||
"hierachy2.3.6.1":{ "$ref":"Match 2.3.6.1"},
|
||||
"hierachy2.3.6.2":{ "ref":"No Match 2.3.6.2"},
|
||||
"hierachy2.3.6.3":{ "ref":"No Match 2.3.6.3"},
|
||||
"hierachy2.3.6.4":{ "ref":"No Match 2.3.6.4"},
|
||||
"hierachy2.3.6.5":{ "ref":"No Match 2.3.6.5"}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let expected = [
|
||||
"Match Root",
|
||||
"Match Subset1",
|
||||
"Match 2.1.1",
|
||||
"Match 2.1.4",
|
||||
"Match 2.2.2",
|
||||
"Match 2.2.5",
|
||||
"Match 2.3.6.1"
|
||||
];
|
||||
|
||||
select(json, expected, ['$..$ref', '$..["$ref"]'] );
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user