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:
Benoit Blanchon
2018-03-01 09:24:58 +01:00
parent 7a2a64803a
commit 83d73c93f7
38 changed files with 238 additions and 233 deletions

View File

@@ -12,7 +12,6 @@
#include "Data/JsonVariantType.hpp"
#include "JsonVariantBase.hpp"
#include "RawJson.hpp"
#include "Serialization/JsonPrintable.hpp"
#include "TypeTraits/EnableIf.hpp"
#include "TypeTraits/IsChar.hpp"
#include "TypeTraits/IsFloatingPoint.hpp"
@@ -28,6 +27,10 @@ namespace ArduinoJson {
// Forward declarations.
class JsonArray;
class JsonObject;
namespace Internals {
template <typename Print>
class JsonSerializer;
}
// A variant that can be a any value serializable to a JSON value.
//
@@ -194,7 +197,7 @@ class JsonVariant : public Internals::JsonVariantBase<JsonVariant> {
const char *cstr = variantAsString();
if (cstr) return T(cstr);
T s;
printTo(s);
serializeJson(*this, s);
return s;
}
//