aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/json.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-07-24 22:17:03 +0200
committerJay Berkenbilt <ejb@ql.org>2022-07-24 22:17:03 +0200
commitf8d1ab946205440ed3c44511ef42e5ad13fb9e5e (patch)
treeb9cae2ce60a010300777528063932d80307a7746 /libtests/json.cc
parentb3e6d445cbf73da2b00062c3f639c2453041ee41 (diff)
downloadqpdf-f8d1ab946205440ed3c44511ef42e5ad13fb9e5e.tar.zst
JSON schema -- accept single item in place of array
When the schema wants a variable-length array, allow a single item as well as allowing an array.
Diffstat (limited to 'libtests/json.cc')
-rw-r--r--libtests/json.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/libtests/json.cc b/libtests/json.cc
index 9c5720f4..a509c2be 100644
--- a/libtests/json.cc
+++ b/libtests/json.cc
@@ -162,7 +162,9 @@ test_schema()
"x": "ecks"
},
"s": [
- "esses"
+ {
+ "ss": "esses"
+ }
]
}
},
@@ -236,6 +238,8 @@ test_schema()
JSON bad_schema = JSON::parse(R"({"a": true, "b": "potato?"})");
check_schema(bad_schema, bad_schema, 0, false, "bad schema field type");
+ // "two" exercises the case of the JSON containing a single
+ // element where the schema has an array.
JSON good = JSON::parse(R"(
{
"one": {
@@ -245,17 +249,15 @@ test_schema()
"x": [1, null]
},
"s": [
- null,
- "anything"
+ {"ss": null},
+ {"ss": "anything"}
]
}
},
- "two": [
- {
- "glarp": "enspliel",
- "goose": 3.14
- }
- ],
+ "two": {
+ "glarp": "enspliel",
+ "goose": 3.14
+ },
"three": {
"<objid>": {
"z": "ebra"