aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-02-06 15:35:07 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-02-07 15:02:57 +0200
commitac2974380f1986480b3a974d97dd120f81c3e2af (patch)
tree336820da30501602ae7c27ef20e0cb39ea13acad /tests
parent36d6b4e5549dc45baf890105de5ef487211f0144 (diff)
Add support for nested subscript, use for json access
Diffstat (limited to 'tests')
-rw-r--r--tests/type/json/testscript29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/type/json/testscript b/tests/type/json/testscript
index d9827df..2663a22 100644
--- a/tests/type/json/testscript
+++ b/tests/type/json/testscript
@@ -329,6 +329,35 @@
{"two":2}
EOO
+ : nested
+ :
+ $* <<EOI >>EOO
+ o = [json] one@([json] 1 2 ([json] a@3 b@4)) two@([json] x@x y@([json] 5 6))
+ print ($o[one][1])
+ print ($o[one][2][b])
+ print ($o[two][y][1])
+ print ($o[two][bogus][junk])
+ print ($o[two][bogus][junk][garbage])
+
+ a = [json] ([json] one@1 two@([json] 2 3)) ([json] 4 5)
+ print ($a[0][one])
+ print ($a[0][two][1])
+ print ($a[1][1])
+ print ($a[1][123][junk])
+ print ($a[1][123][junk][garbage])
+ EOI
+ 2
+ 4
+ 6
+ [null]
+ [null]
+ 1
+ 3
+ 5
+ [null]
+ [null]
+ EOO
+
: reverse
:
$* <<EOI >>EOO