Add JSON::isDictionary and JSON::isArray

This commit is contained in:
Jay Berkenbilt 2022-01-17 18:38:05 -05:00
parent 5c5e5ca29b
commit aa0a379b37
3 changed files with 24 additions and 0 deletions

View File

@ -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.

View File

@ -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:

View File

@ -293,6 +293,20 @@ JSON::makeNull()
return JSON(new JSON_null());
}
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)
{