aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-01-18 00:38:05 +0100
committerJay Berkenbilt <ejb@ql.org>2022-01-30 19:11:03 +0100
commitaa0a379b37889caad022ec12fba76990b2e2e2d9 (patch)
tree6b8ca4c09078fca819dfcd0b374c78dfb1833ec3
parent5c5e5ca29b20877614d9b1c025b86707e67e548b (diff)
downloadqpdf-aa0a379b37889caad022ec12fba76990b2e2e2d9.tar.zst
Add JSON::isDictionary and JSON::isArray
-rw-r--r--ChangeLog4
-rw-r--r--include/qpdf/JSON.hh6
-rw-r--r--libqpdf/JSON.cc14
3 files changed, 24 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 8fa0d315..696915ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,10 @@
to QPDFObjectHandle with corresponding functions added to the C
API. Thanks to m-holger for the contribution.
+2022-01-17 Jay Berkenbilt <ejb@ql.org>
+
+ * Add isDictionary and isArray to JSON
+
2022-01-11 Jay Berkenbilt <ejb@ql.org>
* Bug fix: add missing characters from PDF doc encoding.
diff --git a/include/qpdf/JSON.hh b/include/qpdf/JSON.hh
index 3618d1e7..11fe2c7b 100644
--- a/include/qpdf/JSON.hh
+++ b/include/qpdf/JSON.hh
@@ -69,6 +69,12 @@ class JSON
QPDF_DLL
static JSON makeNull();
+ QPDF_DLL
+ bool isArray() const;
+
+ QPDF_DLL
+ bool isDictionary() const;
+
// Check this JSON object against a "schema". This is not a schema
// according to any standard. It's just a template of what the
// JSON is supposed to contain. The checking does the following:
diff --git a/libqpdf/JSON.cc b/libqpdf/JSON.cc
index f75935aa..c656bb14 100644
--- a/libqpdf/JSON.cc
+++ b/libqpdf/JSON.cc
@@ -294,6 +294,20 @@ JSON::makeNull()
}
bool
+JSON::isArray() const
+{
+ return nullptr != dynamic_cast<JSON_array const*>(
+ this->m->value.getPointer());
+}
+
+bool
+JSON::isDictionary() const
+{
+ return nullptr != dynamic_cast<JSON_dictionary const*>(
+ this->m->value.getPointer());
+}
+
+bool
JSON::checkSchema(JSON schema, std::list<std::string>& errors)
{
return checkSchemaInternal(this->m->value.getPointer(),