Added nested traversal examples

This commit is contained in:
Mike Farah
2021-06-10 08:31:26 +10:00
parent b6e2a96ead
commit 78af68f436
2 changed files with 47 additions and 0 deletions
+16
View File
@@ -77,6 +77,14 @@ var traversePathOperatorScenarios = []expressionScenario{
"D0, P[{}], (!!str)::frog\n",
},
},
{
description: "Multiple special characters",
document: `a: {"key.withdots": {"another.key": apple}}`,
expression: `.a["key.withdots"]["another.key"]`,
expected: []string{
"D0, P[a key.withdots another.key], (!!str)::apple\n",
},
},
{
description: "Keys with spaces",
subdescription: "Use quotes with brackets around path elements with special characters",
@@ -244,6 +252,14 @@ var traversePathOperatorScenarios = []expressionScenario{
"D0, P[0], (!!int)::1\n",
},
},
{
description: "Traversing nested arrays by index",
document: `[[], [cat]]`,
expression: `.[1][0]`,
expected: []string{
"D0, P[1 0], (!!str)::cat\n",
},
},
{
description: "Maps with numeric keys",
document: `{2: cat}`,