forked from bblanchon/ArduinoJson
Replaced printTo()
with serializeJson()
* Added `serializeJson()` and `serializeJsonPretty()` * Added `measureJson()` and `measureJsonPretty()` * Removed `printTo()` and `prettyPrintTo()` * Removed `measureLength()` and `measurePrettyLength()`
This commit is contained in:
@ -72,7 +72,7 @@ void saveConfiguration(const char *filename, const Config &config) {
|
||||
root["port"] = config.port;
|
||||
|
||||
// Serialize JSON to file
|
||||
if (root.printTo(file) == 0) {
|
||||
if (serializeJson(root, file) == 0) {
|
||||
Serial.println(F("Failed to write to file"));
|
||||
}
|
||||
|
||||
|
@ -38,13 +38,13 @@ void setup() {
|
||||
data.add(48.756080);
|
||||
data.add(2.302038);
|
||||
|
||||
root.printTo(Serial);
|
||||
serializeJson(root, Serial);
|
||||
// This prints:
|
||||
// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
|
||||
|
||||
Serial.println();
|
||||
|
||||
root.prettyPrintTo(Serial);
|
||||
serializeJsonPretty(root, Serial);
|
||||
// This prints:
|
||||
// {
|
||||
// "sensor": "gps",
|
||||
|
@ -76,7 +76,7 @@ void loop() {
|
||||
}
|
||||
|
||||
Serial.print(F("Sending: "));
|
||||
root.printTo(Serial);
|
||||
serializeJson(root, Serial);
|
||||
Serial.println();
|
||||
|
||||
// Write response headers
|
||||
@ -86,7 +86,7 @@ void loop() {
|
||||
client.println();
|
||||
|
||||
// Write JSON document
|
||||
root.prettyPrintTo(client);
|
||||
serializeJsonPretty(root, client);
|
||||
|
||||
// Disconnect
|
||||
client.stop();
|
||||
|
@ -72,11 +72,11 @@ void loop() {
|
||||
Serial.print(remoteIp);
|
||||
Serial.print(F(" on port "));
|
||||
Serial.println(remotePort);
|
||||
root.printTo(Serial);
|
||||
serializeJson(root, Serial);
|
||||
|
||||
// Send UDP packet
|
||||
udp.beginPacket(remoteIp, remotePort);
|
||||
root.printTo(udp);
|
||||
serializeJson(root, udp);
|
||||
udp.println();
|
||||
udp.endPacket();
|
||||
|
||||
|
@ -54,7 +54,7 @@ void setup() {
|
||||
|
||||
// Lastly, you can print the resulting JSON to a String
|
||||
String output;
|
||||
root.printTo(output);
|
||||
serializeJson(root, output);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
Reference in New Issue
Block a user