diff options
author | Steve Bennett <steveb@workware.net.au> | 2024-08-27 23:42:03 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2024-08-28 11:59:05 +1000 |
commit | 0bab3745bb1abcea2b1c3210ac7ddc97975608d1 (patch) | |
tree | 29a963825af2ac243247d4378c774f2e8e0643c4 /tests/json.test | |
parent | 590ceb4a2f220f4ef3e07d7819858204590e5718 (diff) | |
download | jimtcl-0bab3745bb1abcea2b1c3210ac7ddc97975608d1.zip jimtcl-0bab3745bb1abcea2b1c3210ac7ddc97975608d1.tar.gz jimtcl-0bab3745bb1abcea2b1c3210ac7ddc97975608d1.tar.bz2 |
json::decode: run parser in strict mode
To avoid invalid JSON causing core dumps.
Minor changes to the jsmn parser to still allow
Infinity and NaN.
Fix some tests that didn't use strictly correct JSON.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests/json.test')
-rw-r--r-- | tests/json.test | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/json.test b/tests/json.test index ed73401..78a19fa 100644 --- a/tests/json.test +++ b/tests/json.test @@ -60,6 +60,7 @@ test json-decode-012 {default null value} { } {null} test json-decode-1.1 {Number forms} { + # Note that this is not strictly correct JSON, but is usable in practice json::decode {[ 1, 2, 3.0, 4, Infinity, NaN, -Infinity, -0.0, 1e5, -1e-5 ]} } {1 2 3.0 4 Inf NaN -Inf -0.0 1e5 -1e-5} @@ -80,15 +81,15 @@ test json-2.4 {schema tests} { } {obj a num b num} test json-2.5 {schema tests} { - lindex [json::decode -schema {[1, 2, {a:"b", c:false}, "hello"]}] 1 + lindex [json::decode -schema {[1, 2, {"a":"b", "c":false}, "hello"]}] 1 } {mixed num num {obj a str c bool} str} test json-2.6 {schema tests} { - lindex [json::decode -schema {[1, 2, {a:["b", 1, true, Infinity]}]}] 1 + lindex [json::decode -schema {[1, 2, {"a":["b", 1, true, Infinity]}]}] 1 } {mixed num num {obj a {mixed str num bool num}}} test json-2.7 {schema tests} { - lindex [json::decode -schema {[1, 2, {a:["b", 1, true, ["d", "e", "f"]]}]}] 1 + lindex [json::decode -schema {[1, 2, {"a":["b", 1, true, ["d", "e", "f"]]}]}] 1 } {mixed num num {obj a {mixed str num bool {list str}}}} test json-2.8 {schema tests} { @@ -96,10 +97,9 @@ test json-2.8 {schema tests} { } {mixed num num bool bool} test json-2.9 {schema tests} { - lindex [json::decode -schema {[{a:1},{b:2}]}] 1 + 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"]} |