我正在尝试使用ArduinoJson来解析谷歌的quickdraw数据集,其中包含.ndjson文件,其中包含多个对象。我知道如何使用以下简单的代码检索文件中的第一个对象:
DeserializationError deserialization_error = ArduinoJson::deserializeJson(doc, as_cstr);
if (deserialization_error) {
printf("deserializeJson() failed: %s\n", deserialization_error.c_str());
}但是,这只解析ndjson文件中的第一个对象。
根据website的说法,我感觉其他事情应该会自动发生:
NDJSON, JSON Lines
When parsing a JSON document from an input stream, ArduinoJson stops reading as soon as the document ends (e.g., at the closing brace).
This feature allows to read JSON documents one after the other; for example, it allows to read line-delimited formats like NDJSON or JSON Lines.
{"event":"add_to_cart"}
{"event":"purchase"}有没有办法获得被解析对象的字节长度,以便我可以继续使用cstring来解析连续的对象?我确实打印出了cstring,并且它包含了整个ndjson文件。
发布于 2020-07-13 04:26:30
我找到了。
只需多次调用:
DeserializationError error = deserializeJson(doc, sceneFile);或者:
deserializeJson(docline1, sceneFile);
deserializeJson(docline2, sceneFile);
deserializeJson(docline3, sceneFile);https://stackoverflow.com/questions/62093402
复制相似问题