From fcc239ecdbd1467a4ac8b17a353e1b0ae7fd63a0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 6 Feb 2024 16:51:24 +0200 Subject: Map JSON null in subscript/iteration to [null] instead of empty This in fact feels more natural in the "for consumption" model and also helps with the nested subscript semantics. --- tests/type/json/testscript | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/type/json/testscript b/tests/type/json/testscript index 2663a22..5295fbc 100644 --- a/tests/type/json/testscript +++ b/tests/type/json/testscript @@ -303,7 +303,7 @@ print ($j[4]) EOI 2 - + [null] [null] EOO @@ -316,7 +316,7 @@ print ($j[five]) EOI 2 - + [null] [null] EOO @@ -332,30 +332,38 @@ : nested : $* <>EOO - o = [json] one@([json] 1 2 ([json] a@3 b@4)) two@([json] x@x y@([json] 5 6)) + o = [json] one@([json] 1 2 ([json] a@3 b@4) null) 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]) + print ($o[one][3][junk]) # JSON null + print ($o[one][3][junk][garbage]) - a = [json] ([json] one@1 two@([json] 2 3)) ([json] 4 5) + a = [json] ([json] one@1 two@([json] 2 3)) ([json] 4 5) null print ($a[0][one]) print ($a[0][two][1]) print ($a[1][1]) print ($a[1][123][junk]) print ($a[1][123][junk][garbage]) + print ($a[2][junk]) # JSON null + print ($a[2][junk][garbage]) EOI 2 4 6 [null] [null] + [null] + [null] 1 3 5 [null] [null] + [null] + [null] EOO : reverse @@ -368,7 +376,7 @@ print (([json] one@0xdecaf)[one]) print (([json] one@abc)[one]) EOI - + [null] true 123 -123 @@ -435,7 +443,7 @@ for v: ([json] null true 123 -123 0xdecaf abc) print $v EOI - + [null] true 123 -123 -- cgit v1.1