2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-03 07:12:28 +00:00

JSONHandler: pass JSON object to array start function

This commit is contained in:
Jay Berkenbilt 2022-01-30 13:45:02 -05:00
parent b74e7989c3
commit 3b60224bae
4 changed files with 12 additions and 7 deletions

View File

@ -69,7 +69,7 @@ JSONHandler::addFallbackDictHandler(std::shared_ptr<JSONHandler> fdh)
}
void
JSONHandler::addArrayHandlers(void_handler_t start_fn,
JSONHandler::addArrayHandlers(json_handler_t start_fn,
void_handler_t end_fn,
std::shared_ptr<JSONHandler> ah)
{
@ -144,7 +144,7 @@ JSONHandler::handle(std::string const& path, JSON j)
}
if (this->m->h.array_start_handler && j.isArray())
{
this->m->h.array_start_handler(path);
this->m->h.array_start_handler(path, j);
size_t i = 0;
j.forEachArrayItem([&i, &path, this](JSON v) {
this->m->h.array_item_handler->handle(

View File

@ -66,7 +66,7 @@ class JSONHandler
void addFallbackDictHandler(std::shared_ptr<JSONHandler>);
QPDF_DLL
void addArrayHandlers(void_handler_t start_fn,
void addArrayHandlers(json_handler_t start_fn,
void_handler_t end_fn,
std::shared_ptr<JSONHandler> item_handlers);
@ -102,7 +102,7 @@ class JSONHandler
bool_handler_t bool_handler;
json_handler_t dict_start_handler;
void_handler_t dict_end_handler;
void_handler_t array_start_handler;
json_handler_t array_start_handler;
void_handler_t array_end_handler;
void_handler_t final_handler;
std::map<std::string, std::shared_ptr<JSONHandler>> dict_handlers;

View File

@ -71,8 +71,7 @@ static std::shared_ptr<JSONHandler> make_all_handler()
auto h5s = std::make_shared<JSONHandler>();
h->addDictKeyHandler("five", h5s);
h5s->addArrayHandlers(
make_print_message("array begin"),
make_print_message("array end"),
print_json, make_print_message("array end"),
h5);
auto h6 = std::make_shared<JSONHandler>();
h6->addDictHandlers(

View File

@ -25,7 +25,13 @@
"three": true,
"two": 3.14
}
.five: json: array begin
.five: json: [
"x",
false,
"y",
null,
true
]
.five[0]: string: x
.five[1]: bool: false
.five[2]: string: y