aboutsummaryrefslogtreecommitdiff
path: root/tests/json.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/json.test')
-rw-r--r--tests/json.test24
1 files changed, 24 insertions, 0 deletions
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} {