初始化提交

This commit is contained in:
王立帮
2024-07-20 22:09:06 +08:00
commit c247dd07a6
6876 changed files with 2743096 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
#include "ExampleParser.h"
#include "JsonListener.h"
void ExampleListener::whitespace(char c) {
Serial.println("whitespace");
}
void ExampleListener::startDocument() {
Serial.println("start document");
}
void ExampleListener::key(String key) {
Serial.println("key: " + key);
}
void ExampleListener::value(String value) {
Serial.println("value: " + value);
}
void ExampleListener::endArray() {
Serial.println("end array. ");
}
void ExampleListener::endObject() {
Serial.println("end object. ");
}
void ExampleListener::endDocument() {
Serial.println("end document. ");
}
void ExampleListener::startArray() {
Serial.println("start array. ");
}
void ExampleListener::startObject() {
Serial.println("start object. ");
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include "JsonListener.h"
class ExampleListener: public JsonListener {
public:
virtual void whitespace(char c);
virtual void startDocument();
virtual void key(String key);
virtual void value(String value);
virtual void endArray();
virtual void endObject();
virtual void endDocument();
virtual void startArray();
virtual void startObject();
};

View File

@@ -0,0 +1,23 @@
#include "JsonStreamingParser.h"
#include "JsonListener.h"
#include "ExampleParser.h"
JsonStreamingParser parser;
ExampleListener listener;
void setup() {
Serial.begin(115200);
Serial.println(String(ESP.getFreeHeap()));
parser.setListener(&listener);
// put your setup code here, to run once:
char json[] = "{\"a\":3, \"b\":{\"c\":\"d\"}}";
for (int i = 0; i < sizeof(json); i++) {
parser.parse(json[i]);
}
Serial.println(String(ESP.getFreeHeap()));
}
void loop() {
// put your main code here, to run repeatedly:
}