Distinguish on_string_data and on_key_data

This commit is contained in:
2025-08-04 14:15:49 -04:00
parent 39fe9be4dc
commit bcb5a20f27
5 changed files with 107 additions and 11 deletions

View File

@@ -79,6 +79,18 @@ inline WeaselJsonCallbacks readValueCallbacks() {
state->on_end_value();
}
};
result.on_key_data = +[](void *p, const char *buf, int len, int done) {
auto *state = (ReadValueState *)p;
if (!state->startedData) {
state->startedData = true;
state->valueStack.emplace_back(std::string());
}
std::get<std::string>(state->valueStack.back()).append(buf, len);
if (done) {
state->startedData = false;
state->on_end_value();
}
};
result.on_begin_array = +[](void *p) {
auto *state = (ReadValueState *)p;
state->valueStack.emplace_back(std::make_unique<JsonArray>());