diff --git a/JsonGenerator/JsonValue.cpp b/JsonGenerator/JsonValue.cpp index 01a2c9d3..41d74e64 100644 --- a/JsonGenerator/JsonValue.cpp +++ b/JsonGenerator/JsonValue.cpp @@ -12,11 +12,6 @@ size_t JsonValue::printBoolTo(const Content& c, Print& p) return p.print(c.asBool ? "true" : "false"); } -size_t JsonValue::printDoubleTo(const Content& c, Print& p) -{ - return p.print(c.asDouble.value, c.asDouble.digits); -} - size_t JsonValue::printLongTo(const Content& c, Print& p) { return p.print(c.asLong); diff --git a/JsonGenerator/JsonValue.h b/JsonGenerator/JsonValue.h index cf2defc8..fb3ad903 100644 --- a/JsonGenerator/JsonValue.h +++ b/JsonGenerator/JsonValue.h @@ -49,9 +49,8 @@ namespace ArduinoJson template void set(double value) { - printToImpl = &printDoubleTo; - content.asDouble.value = value; - content.asDouble.digits = DIGITS; + printToImpl = &printDoubleTo; + content.asDouble = value; } size_t printTo(Print& p) const @@ -67,22 +66,23 @@ namespace ArduinoJson long asLong; Printable* asPrintable; const char* asString; - - struct { - double value; - uint8_t digits; - } asDouble; + double asDouble; }; Content content; - size_t(*printToImpl)(const Content&, Print& p); + size_t(*printToImpl)(const Content&, Print&); - static size_t printBoolTo(const Content&, Print& p); - static size_t printDoubleTo(const Content&, Print& p); - static size_t printLongTo(const Content&, Print& p); - static size_t printPrintableTo(const Content&, Print& p); - static size_t printStringTo(const Content&, Print& p); + static size_t printBoolTo(const Content&, Print&); + static size_t printLongTo(const Content&, Print&); + static size_t printPrintableTo(const Content&, Print&); + static size_t printStringTo(const Content&, Print&); + + template + static size_t printDoubleTo(const Content& c, Print& p) + { + return p.print(c.asDouble, DIGITS); + } }; } } \ No newline at end of file