From ea69c35ddd6842bca86711e504968236b70cf426 Mon Sep 17 00:00:00 2001 From: dbohdan Date: Sat, 9 Nov 2019 19:54:10 +0000 Subject: json: implement -index decode option --- tests/json.test | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/json.test') diff --git a/tests/json.test b/tests/json.test index 8dfa567..ed73401 100644 --- a/tests/json.test +++ b/tests/json.test @@ -99,6 +99,30 @@ test json-2.9 {schema tests} { lindex [json::decode -schema {[{a:1},{b:2}]}] 1 } {mixed {obj a num} {obj b num}} + +test json-3.1 {-index array} { + json::decode -index \ + {[null, 1, 2, true, false, "hello"]} +} {0 null 1 1 2 2 3 true 4 false 5 hello} + +test json-3.2 {-index array and object} { + json::decode -index \ + {{"outer": [{"key": "value"}, {"key2": "value2"}]}} +} {outer {0 {key value} 1 {key2 value2}}} + +test json-3.3 {-index array with -schema} { + json::decode -index -schema \ + {[null, 1, 2, true, false, "hello"]} +} "{0 null 1 1 2 2 3 true 4 false 5 hello}\ + {mixed num num num bool bool str}" + +test json-3.4 {-index array with -schema 2} { + json::decode -index -schema \ + {{"outer": [{"key": "value"}, {"key2": "value2"}]}} +} "{outer {0 {key value} 1 {key2 value2}}}\ + {obj outer {mixed {obj key str} {obj key2 str}}}" + + unset -nocomplain json test json-encode-1.1 {String with backslashes} { -- cgit v1.1