diff --git a/include/ArduinoJson.hpp b/include/ArduinoJson.hpp index b8281073..05085464 100644 --- a/include/ArduinoJson.hpp +++ b/include/ArduinoJson.hpp @@ -13,11 +13,11 @@ #include "ArduinoJson/JsonVariantComparisons.hpp" #include "ArduinoJson/StaticJsonBuffer.hpp" -#include "ArduinoJson/Internals/JsonParserImpl.hpp" -#include "ArduinoJson/Internals/JsonSerializerImpl.hpp" +#include "ArduinoJson/Deserialization/JsonParserImpl.hpp" #include "ArduinoJson/JsonArrayImpl.hpp" #include "ArduinoJson/JsonBufferImpl.hpp" #include "ArduinoJson/JsonObjectImpl.hpp" #include "ArduinoJson/JsonVariantImpl.hpp" +#include "ArduinoJson/Serialization/JsonSerializerImpl.hpp" using namespace ArduinoJson; diff --git a/include/ArduinoJson/Internals/BlockJsonBuffer.hpp b/include/ArduinoJson/Data/BlockJsonBuffer.hpp similarity index 100% rename from include/ArduinoJson/Internals/BlockJsonBuffer.hpp rename to include/ArduinoJson/Data/BlockJsonBuffer.hpp diff --git a/include/ArduinoJson/Internals/Encoding.hpp b/include/ArduinoJson/Data/Encoding.hpp similarity index 100% rename from include/ArduinoJson/Internals/Encoding.hpp rename to include/ArduinoJson/Data/Encoding.hpp diff --git a/include/ArduinoJson/Internals/JsonBufferAllocated.hpp b/include/ArduinoJson/Data/JsonBufferAllocated.hpp similarity index 100% rename from include/ArduinoJson/Internals/JsonBufferAllocated.hpp rename to include/ArduinoJson/Data/JsonBufferAllocated.hpp diff --git a/include/ArduinoJson/Internals/JsonFloat.hpp b/include/ArduinoJson/Data/JsonFloat.hpp similarity index 100% rename from include/ArduinoJson/Internals/JsonFloat.hpp rename to include/ArduinoJson/Data/JsonFloat.hpp diff --git a/include/ArduinoJson/Internals/JsonInteger.hpp b/include/ArduinoJson/Data/JsonInteger.hpp similarity index 100% rename from include/ArduinoJson/Internals/JsonInteger.hpp rename to include/ArduinoJson/Data/JsonInteger.hpp diff --git a/include/ArduinoJson/Internals/JsonVariantAs.hpp b/include/ArduinoJson/Data/JsonVariantAs.hpp similarity index 100% rename from include/ArduinoJson/Internals/JsonVariantAs.hpp rename to include/ArduinoJson/Data/JsonVariantAs.hpp diff --git a/include/ArduinoJson/Internals/JsonVariantContent.hpp b/include/ArduinoJson/Data/JsonVariantContent.hpp similarity index 100% rename from include/ArduinoJson/Internals/JsonVariantContent.hpp rename to include/ArduinoJson/Data/JsonVariantContent.hpp diff --git a/include/ArduinoJson/Internals/JsonVariantDefault.hpp b/include/ArduinoJson/Data/JsonVariantDefault.hpp similarity index 100% rename from include/ArduinoJson/Internals/JsonVariantDefault.hpp rename to include/ArduinoJson/Data/JsonVariantDefault.hpp diff --git a/include/ArduinoJson/Internals/JsonVariantType.hpp b/include/ArduinoJson/Data/JsonVariantType.hpp similarity index 100% rename from include/ArduinoJson/Internals/JsonVariantType.hpp rename to include/ArduinoJson/Data/JsonVariantType.hpp diff --git a/include/ArduinoJson/Internals/List.hpp b/include/ArduinoJson/Data/List.hpp similarity index 100% rename from include/ArduinoJson/Internals/List.hpp rename to include/ArduinoJson/Data/List.hpp diff --git a/include/ArduinoJson/Internals/ListConstIterator.hpp b/include/ArduinoJson/Data/ListConstIterator.hpp similarity index 100% rename from include/ArduinoJson/Internals/ListConstIterator.hpp rename to include/ArduinoJson/Data/ListConstIterator.hpp diff --git a/include/ArduinoJson/Internals/ListIterator.hpp b/include/ArduinoJson/Data/ListIterator.hpp similarity index 100% rename from include/ArduinoJson/Internals/ListIterator.hpp rename to include/ArduinoJson/Data/ListIterator.hpp diff --git a/include/ArduinoJson/Internals/ListNode.hpp b/include/ArduinoJson/Data/ListNode.hpp similarity index 100% rename from include/ArduinoJson/Internals/ListNode.hpp rename to include/ArduinoJson/Data/ListNode.hpp diff --git a/include/ArduinoJson/Internals/Parse.hpp b/include/ArduinoJson/Data/Parse.hpp similarity index 100% rename from include/ArduinoJson/Internals/Parse.hpp rename to include/ArduinoJson/Data/Parse.hpp diff --git a/include/ArduinoJson/Internals/ReferenceType.hpp b/include/ArduinoJson/Data/ReferenceType.hpp similarity index 100% rename from include/ArduinoJson/Internals/ReferenceType.hpp rename to include/ArduinoJson/Data/ReferenceType.hpp diff --git a/include/ArduinoJson/Internals/StringFuncs.hpp b/include/ArduinoJson/Data/StringFuncs.hpp similarity index 100% rename from include/ArduinoJson/Internals/StringFuncs.hpp rename to include/ArduinoJson/Data/StringFuncs.hpp diff --git a/include/ArduinoJson/Internals/ValueSetter.hpp b/include/ArduinoJson/Data/ValueSetter.hpp similarity index 100% rename from include/ArduinoJson/Internals/ValueSetter.hpp rename to include/ArduinoJson/Data/ValueSetter.hpp diff --git a/include/ArduinoJson/Deserialization/Comments.hpp b/include/ArduinoJson/Deserialization/Comments.hpp new file mode 100644 index 00000000..eb70cc7e --- /dev/null +++ b/include/ArduinoJson/Deserialization/Comments.hpp @@ -0,0 +1,76 @@ +// Copyright Benoit Blanchon 2014-2016 +// MIT License +// +// Arduino JSON library +// https://github.com/bblanchon/ArduinoJson +// If you like this project, please add a star! + +#pragma once + +namespace ArduinoJson { +namespace Internals { +template +void skipSpacesAndComments(TInput& input) { + for (;;) { + switch (input.peek()) { + // spaces + case ' ': + case '\t': + case '\r': + case '\n': + input.skip(); + continue; + + // comments + case '/': + switch (input.peekNext()) { + // C-style block comment + case '*': + input.skip(); // skip '/' + input.skip(); // skip '*' + for (;;) { + switch (input.peek()) { + case '\0': + return; + case '*': + input.skip(); // skip '*' + if (input.peek() == '/') { + input.skip(); // skip '/' + return; + } + break; + default: + input.skip(); + } + } + break; + + // C++-style line comment + case '/': + input.skip(); // skip '/' + for (;;) { + switch (input.peek()) { + case '\0': + return; + case '\n': + input.skip(); + return; + default: + input.skip(); + } + } + return; + + // not a comment, just a '/' + default: + return; + } + break; + + default: + return; + } + } +} +} +} diff --git a/include/ArduinoJson/Internals/JsonParser.hpp b/include/ArduinoJson/Deserialization/JsonParser.hpp similarity index 84% rename from include/ArduinoJson/Internals/JsonParser.hpp rename to include/ArduinoJson/Deserialization/JsonParser.hpp index bdbd12bd..1955488e 100644 --- a/include/ArduinoJson/Internals/JsonParser.hpp +++ b/include/ArduinoJson/Deserialization/JsonParser.hpp @@ -9,6 +9,8 @@ #include "../JsonBuffer.hpp" #include "../JsonVariant.hpp" +#include "StringReader.hpp" +#include "StringWriter.hpp" namespace ArduinoJson { namespace Internals { @@ -20,8 +22,8 @@ class JsonParser { public: JsonParser(JsonBuffer *buffer, char *json, uint8_t nestingLimit) : _buffer(buffer), - _readPtr(json ? json : ""), - _writePtr(json), + _reader(json), + _writer(json), _nestingLimit(nestingLimit) {} JsonArray &parseArray(); @@ -34,7 +36,10 @@ class JsonParser { } private: - bool skip(char charToSkip); + static bool eat(StringReader &, char charToSkip); + FORCE_INLINE bool eat(char charToSkip) { + return eat(_reader, charToSkip); + } const char *parseString(); bool parseAnythingTo(JsonVariant *destination); @@ -58,8 +63,8 @@ class JsonParser { } JsonBuffer *_buffer; - const char *_readPtr; - char *_writePtr; + StringReader _reader; + StringWriter _writer; uint8_t _nestingLimit; }; } diff --git a/include/ArduinoJson/Internals/JsonParserImpl.hpp b/include/ArduinoJson/Deserialization/JsonParserImpl.hpp similarity index 71% rename from include/ArduinoJson/Internals/JsonParserImpl.hpp rename to include/ArduinoJson/Deserialization/JsonParserImpl.hpp index efc10279..ef0315eb 100644 --- a/include/ArduinoJson/Internals/JsonParserImpl.hpp +++ b/include/ArduinoJson/Deserialization/JsonParserImpl.hpp @@ -10,11 +10,12 @@ #include "Comments.hpp" #include "JsonParser.hpp" -inline bool ArduinoJson::Internals::JsonParser::skip(char charToSkip) { - const char *ptr = skipSpacesAndComments(_readPtr); - if (*ptr != charToSkip) return false; - ptr++; - _readPtr = skipSpacesAndComments(ptr); +inline bool ArduinoJson::Internals::JsonParser::eat(StringReader &reader, + char charToSkip) { + skipSpacesAndComments(reader); + if (reader.peek() != charToSkip) return false; + reader.skip(); + skipSpacesAndComments(reader); return true; } @@ -29,9 +30,9 @@ inline bool ArduinoJson::Internals::JsonParser::parseAnythingTo( inline bool ArduinoJson::Internals::JsonParser::parseAnythingToUnsafe( JsonVariant *destination) { - _readPtr = skipSpacesAndComments(_readPtr); + skipSpacesAndComments(_reader); - switch (*_readPtr) { + switch (_reader.peek()) { case '[': return parseArrayTo(destination); @@ -49,8 +50,8 @@ ArduinoJson::Internals::JsonParser::parseArray() { JsonArray &array = _buffer->createArray(); // Check opening braket - if (!skip('[')) goto ERROR_MISSING_BRACKET; - if (skip(']')) goto SUCCESS_EMPTY_ARRAY; + if (!eat('[')) goto ERROR_MISSING_BRACKET; + if (eat(']')) goto SUCCESS_EMPTY_ARRAY; // Read each value for (;;) { @@ -60,8 +61,8 @@ ArduinoJson::Internals::JsonParser::parseArray() { if (!array.add(value)) goto ERROR_NO_MEMORY; // 2 - More values? - if (skip(']')) goto SUCCES_NON_EMPTY_ARRAY; - if (!skip(',')) goto ERROR_MISSING_COMMA; + if (eat(']')) goto SUCCES_NON_EMPTY_ARRAY; + if (!eat(',')) goto ERROR_MISSING_COMMA; } SUCCESS_EMPTY_ARRAY: @@ -90,15 +91,15 @@ ArduinoJson::Internals::JsonParser::parseObject() { JsonObject &object = _buffer->createObject(); // Check opening brace - if (!skip('{')) goto ERROR_MISSING_BRACE; - if (skip('}')) goto SUCCESS_EMPTY_OBJECT; + if (!eat('{')) goto ERROR_MISSING_BRACE; + if (eat('}')) goto SUCCESS_EMPTY_OBJECT; // Read each key value pair for (;;) { // 1 - Parse key const char *key = parseString(); if (!key) goto ERROR_INVALID_KEY; - if (!skip(':')) goto ERROR_MISSING_COLON; + if (!eat(':')) goto ERROR_MISSING_COLON; // 2 - Parse value JsonVariant value; @@ -106,8 +107,8 @@ ArduinoJson::Internals::JsonParser::parseObject() { if (!object.set(key, value)) goto ERROR_NO_MEMORY; // 3 - More keys/values? - if (skip('}')) goto SUCCESS_NON_EMPTY_OBJECT; - if (!skip(',')) goto ERROR_MISSING_COMMA; + if (eat('}')) goto SUCCESS_NON_EMPTY_OBJECT; + if (!eat(',')) goto ERROR_MISSING_COMMA; } SUCCESS_EMPTY_OBJECT: @@ -133,53 +134,45 @@ inline bool ArduinoJson::Internals::JsonParser::parseObjectTo( } inline const char *ArduinoJson::Internals::JsonParser::parseString() { - const char *readPtr = _readPtr; - char *writePtr = _writePtr; + const char *str = _writer.startString(); - char c = *readPtr; + char c = _reader.peek(); if (isQuote(c)) { // quotes + _reader.skip(); char stopChar = c; for (;;) { - c = *++readPtr; + c = _reader.peek(); if (c == '\0') break; + _reader.skip(); - if (c == stopChar) { - readPtr++; - break; - } + if (c == stopChar) break; if (c == '\\') { // replace char - c = Encoding::unescapeChar(*++readPtr); + c = Encoding::unescapeChar(_reader.peek()); if (c == '\0') break; + _reader.skip(); } - *writePtr++ = c; + _writer.append(c); } } else { // no quotes for (;;) { if (!isLetterOrNumber(c)) break; - *writePtr++ = c; - c = *++readPtr; + _reader.skip(); + _writer.append(c); + c = _reader.peek(); } } - // end the string here - *writePtr++ = '\0'; - const char *startPtr = _writePtr; - - // update end ptr - _readPtr = readPtr; - _writePtr = writePtr; - - // return pointer to unquoted string - return startPtr; + _writer.stopString(); + return str; } inline bool ArduinoJson::Internals::JsonParser::parseStringTo( JsonVariant *destination) { - bool hasQuotes = isQuote(_readPtr[0]); + bool hasQuotes = isQuote(_reader.peek()); const char *value = parseString(); if (value == NULL) return false; if (hasQuotes) { diff --git a/include/ArduinoJson/Deserialization/StringReader.hpp b/include/ArduinoJson/Deserialization/StringReader.hpp new file mode 100644 index 00000000..969540d8 --- /dev/null +++ b/include/ArduinoJson/Deserialization/StringReader.hpp @@ -0,0 +1,36 @@ +// Copyright Benoit Blanchon 2014-2016 +// MIT License +// +// Arduino JSON library +// https://github.com/bblanchon/ArduinoJson +// If you like this project, please add a star! + +#pragma once + +namespace ArduinoJson { +namespace Internals { + +// Parse JSON string to create JsonArrays and JsonObjects +// This internal class is not indended to be used directly. +// Instead, use JsonBuffer.parseArray() or .parseObject() +class StringReader { + public: + StringReader(const char *input) : _ptr(input ? input : "") {} + + void skip() { + _ptr++; + } + + char peek() const { + return _ptr[0]; + } + + char peekNext() const { + return _ptr[1]; + } + + private: + const char *_ptr; +}; +} +} diff --git a/include/ArduinoJson/Deserialization/StringWriter.hpp b/include/ArduinoJson/Deserialization/StringWriter.hpp new file mode 100644 index 00000000..e42ff489 --- /dev/null +++ b/include/ArduinoJson/Deserialization/StringWriter.hpp @@ -0,0 +1,36 @@ +// Copyright Benoit Blanchon 2014-2016 +// MIT License +// +// Arduino JSON library +// https://github.com/bblanchon/ArduinoJson +// If you like this project, please add a star! + +#pragma once + +namespace ArduinoJson { +namespace Internals { + +// Parse JSON string to create JsonArrays and JsonObjects +// This internal class is not indended to be used directly. +// Instead, use JsonBuffer.parseArray() or .parseObject() +class StringWriter { + public: + StringWriter(char *buffer) : _ptr(buffer) {} + + const char *startString() { + return _ptr; + } + + void stopString() { + *_ptr++ = 0; + } + + void append(char c) { + *_ptr++ = c; + } + + private: + char *_ptr; +}; +} +} diff --git a/include/ArduinoJson/DynamicJsonBuffer.hpp b/include/ArduinoJson/DynamicJsonBuffer.hpp index 7dc5b2e8..e2acf57f 100644 --- a/include/ArduinoJson/DynamicJsonBuffer.hpp +++ b/include/ArduinoJson/DynamicJsonBuffer.hpp @@ -7,7 +7,7 @@ #pragma once -#include "Internals/BlockJsonBuffer.hpp" +#include "Data/BlockJsonBuffer.hpp" namespace ArduinoJson { // Implements a JsonBuffer with dynamic memory allocation. diff --git a/include/ArduinoJson/Internals/Comments.hpp b/include/ArduinoJson/Internals/Comments.hpp deleted file mode 100644 index 6e62066a..00000000 --- a/include/ArduinoJson/Internals/Comments.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright Benoit Blanchon 2014-2016 -// MIT License -// -// Arduino JSON library -// https://github.com/bblanchon/ArduinoJson -// If you like this project, please add a star! - -#pragma once - -namespace ArduinoJson { -namespace Internals { -inline const char *skipCStyleComment(const char *ptr) { - ptr += 2; - for (;;) { - if (ptr[0] == '\0') return ptr; - if (ptr[0] == '*' && ptr[1] == '/') return ptr + 2; - ptr++; - } -} - -inline const char *skipCppStyleComment(const char *ptr) { - ptr += 2; - for (;;) { - if (ptr[0] == '\0' || ptr[0] == '\n') return ptr; - ptr++; - } -} - -inline const char *skipSpacesAndComments(const char *ptr) { - for (;;) { - switch (ptr[0]) { - case ' ': - case '\t': - case '\r': - case '\n': - ptr++; - continue; - case '/': - switch (ptr[1]) { - case '*': - ptr = skipCStyleComment(ptr); - break; - case '/': - ptr = skipCppStyleComment(ptr); - break; - default: - return ptr; - } - break; - default: - return ptr; - } - } -} -} -} diff --git a/include/ArduinoJson/JsonArray.hpp b/include/ArduinoJson/JsonArray.hpp index bfc2c386..f60a286a 100644 --- a/include/ArduinoJson/JsonArray.hpp +++ b/include/ArduinoJson/JsonArray.hpp @@ -7,13 +7,13 @@ #pragma once -#include "Internals/JsonBufferAllocated.hpp" -#include "Internals/JsonPrintable.hpp" -#include "Internals/List.hpp" -#include "Internals/ReferenceType.hpp" -#include "Internals/StringFuncs.hpp" -#include "Internals/ValueSetter.hpp" +#include "Data/JsonBufferAllocated.hpp" +#include "Data/List.hpp" +#include "Data/ReferenceType.hpp" +#include "Data/StringFuncs.hpp" +#include "Data/ValueSetter.hpp" #include "JsonVariant.hpp" +#include "Serialization/JsonPrintable.hpp" #include "TypeTraits/ConstRefOrConstPtr.hpp" #include "TypeTraits/EnableIf.hpp" #include "TypeTraits/IsFloatingPoint.hpp" diff --git a/include/ArduinoJson/JsonBufferImpl.hpp b/include/ArduinoJson/JsonBufferImpl.hpp index 6b86f27c..bd0b91bf 100644 --- a/include/ArduinoJson/JsonBufferImpl.hpp +++ b/include/ArduinoJson/JsonBufferImpl.hpp @@ -7,7 +7,7 @@ #pragma once -#include "Internals/JsonParser.hpp" +#include "Deserialization/JsonParser.hpp" inline ArduinoJson::JsonArray &ArduinoJson::JsonBuffer::createArray() { JsonArray *ptr = new (this) JsonArray(this); diff --git a/include/ArduinoJson/JsonObject.hpp b/include/ArduinoJson/JsonObject.hpp index 479d29c0..e27cb959 100644 --- a/include/ArduinoJson/JsonObject.hpp +++ b/include/ArduinoJson/JsonObject.hpp @@ -7,13 +7,13 @@ #pragma once -#include "Internals/JsonBufferAllocated.hpp" -#include "Internals/JsonPrintable.hpp" -#include "Internals/List.hpp" -#include "Internals/ReferenceType.hpp" -#include "Internals/StringFuncs.hpp" -#include "Internals/ValueSetter.hpp" +#include "Data/JsonBufferAllocated.hpp" +#include "Data/List.hpp" +#include "Data/ReferenceType.hpp" +#include "Data/StringFuncs.hpp" +#include "Data/ValueSetter.hpp" #include "JsonPair.hpp" +#include "Serialization/JsonPrintable.hpp" #include "TypeTraits/ConstRefOrConstPtr.hpp" #include "TypeTraits/EnableIf.hpp" #include "TypeTraits/IsFloatingPoint.hpp" diff --git a/include/ArduinoJson/JsonVariant.hpp b/include/ArduinoJson/JsonVariant.hpp index 735821b8..99139026 100644 --- a/include/ArduinoJson/JsonVariant.hpp +++ b/include/ArduinoJson/JsonVariant.hpp @@ -10,12 +10,12 @@ #include #include // for uint8_t -#include "Internals/JsonPrintable.hpp" -#include "Internals/JsonVariantContent.hpp" -#include "Internals/JsonVariantDefault.hpp" -#include "Internals/JsonVariantType.hpp" +#include "Data/JsonVariantContent.hpp" +#include "Data/JsonVariantDefault.hpp" +#include "Data/JsonVariantType.hpp" #include "JsonVariantBase.hpp" #include "RawJson.hpp" +#include "Serialization/JsonPrintable.hpp" #include "TypeTraits/EnableIf.hpp" #include "TypeTraits/IsFloatingPoint.hpp" #include "TypeTraits/IsIntegral.hpp" diff --git a/include/ArduinoJson/JsonVariantBase.hpp b/include/ArduinoJson/JsonVariantBase.hpp index 00fd9338..9ab71b95 100644 --- a/include/ArduinoJson/JsonVariantBase.hpp +++ b/include/ArduinoJson/JsonVariantBase.hpp @@ -7,8 +7,9 @@ #pragma once -#include "Internals/JsonVariantAs.hpp" +#include "Data/JsonVariantAs.hpp" #include "Polyfills/attributes.hpp" +#include "Serialization/JsonPrintable.hpp" namespace ArduinoJson { diff --git a/include/ArduinoJson/JsonVariantImpl.hpp b/include/ArduinoJson/JsonVariantImpl.hpp index a526be64..49456d69 100644 --- a/include/ArduinoJson/JsonVariantImpl.hpp +++ b/include/ArduinoJson/JsonVariantImpl.hpp @@ -8,7 +8,7 @@ #pragma once #include "Configuration.hpp" -#include "Internals/Parse.hpp" +#include "Data/Parse.hpp" #include "JsonArray.hpp" #include "JsonObject.hpp" #include "JsonVariant.hpp" diff --git a/include/ArduinoJson/Internals/DummyPrint.hpp b/include/ArduinoJson/Serialization/DummyPrint.hpp similarity index 100% rename from include/ArduinoJson/Internals/DummyPrint.hpp rename to include/ArduinoJson/Serialization/DummyPrint.hpp diff --git a/include/ArduinoJson/Internals/DynamicStringBuilder.hpp b/include/ArduinoJson/Serialization/DynamicStringBuilder.hpp similarity index 95% rename from include/ArduinoJson/Internals/DynamicStringBuilder.hpp rename to include/ArduinoJson/Serialization/DynamicStringBuilder.hpp index d7d921a1..4651fbda 100644 --- a/include/ArduinoJson/Internals/DynamicStringBuilder.hpp +++ b/include/ArduinoJson/Serialization/DynamicStringBuilder.hpp @@ -7,8 +7,8 @@ #pragma once +#include "../Data/StringFuncs.hpp" #include "../Print.hpp" -#include "StringFuncs.hpp" namespace ArduinoJson { namespace Internals { diff --git a/include/ArduinoJson/Internals/IndentedPrint.hpp b/include/ArduinoJson/Serialization/IndentedPrint.hpp similarity index 100% rename from include/ArduinoJson/Internals/IndentedPrint.hpp rename to include/ArduinoJson/Serialization/IndentedPrint.hpp diff --git a/include/ArduinoJson/Internals/JsonPrintable.hpp b/include/ArduinoJson/Serialization/JsonPrintable.hpp similarity index 100% rename from include/ArduinoJson/Internals/JsonPrintable.hpp rename to include/ArduinoJson/Serialization/JsonPrintable.hpp diff --git a/include/ArduinoJson/Internals/JsonSerializer.hpp b/include/ArduinoJson/Serialization/JsonSerializer.hpp similarity index 100% rename from include/ArduinoJson/Internals/JsonSerializer.hpp rename to include/ArduinoJson/Serialization/JsonSerializer.hpp diff --git a/include/ArduinoJson/Internals/JsonSerializerImpl.hpp b/include/ArduinoJson/Serialization/JsonSerializerImpl.hpp similarity index 100% rename from include/ArduinoJson/Internals/JsonSerializerImpl.hpp rename to include/ArduinoJson/Serialization/JsonSerializerImpl.hpp diff --git a/include/ArduinoJson/Internals/JsonWriter.hpp b/include/ArduinoJson/Serialization/JsonWriter.hpp similarity index 97% rename from include/ArduinoJson/Internals/JsonWriter.hpp rename to include/ArduinoJson/Serialization/JsonWriter.hpp index 8225f951..92027011 100644 --- a/include/ArduinoJson/Internals/JsonWriter.hpp +++ b/include/ArduinoJson/Serialization/JsonWriter.hpp @@ -7,13 +7,13 @@ #pragma once +#include "../Data/Encoding.hpp" +#include "../Data/JsonFloat.hpp" +#include "../Data/JsonInteger.hpp" #include "../Polyfills/attributes.hpp" #include "../Polyfills/math.hpp" #include "../Polyfills/normalize.hpp" #include "../Print.hpp" -#include "Encoding.hpp" -#include "JsonFloat.hpp" -#include "JsonInteger.hpp" namespace ArduinoJson { namespace Internals { diff --git a/include/ArduinoJson/Internals/Prettyfier.hpp b/include/ArduinoJson/Serialization/Prettyfier.hpp similarity index 100% rename from include/ArduinoJson/Internals/Prettyfier.hpp rename to include/ArduinoJson/Serialization/Prettyfier.hpp diff --git a/include/ArduinoJson/Internals/StaticStringBuilder.hpp b/include/ArduinoJson/Serialization/StaticStringBuilder.hpp similarity index 100% rename from include/ArduinoJson/Internals/StaticStringBuilder.hpp rename to include/ArduinoJson/Serialization/StaticStringBuilder.hpp diff --git a/include/ArduinoJson/Internals/StreamPrintAdapter.hpp b/include/ArduinoJson/Serialization/StreamPrintAdapter.hpp similarity index 100% rename from include/ArduinoJson/Internals/StreamPrintAdapter.hpp rename to include/ArduinoJson/Serialization/StreamPrintAdapter.hpp diff --git a/test/JsonParser_Variant_Tests.cpp b/test/JsonParser_Variant_Tests.cpp index 382fc395..e8489263 100644 --- a/test/JsonParser_Variant_Tests.cpp +++ b/test/JsonParser_Variant_Tests.cpp @@ -5,8 +5,8 @@ // https://github.com/bblanchon/ArduinoJson // If you like this project, please add a star! -#include #include +#include class JsonParser_Variant_Test : public testing::Test { protected: @@ -92,7 +92,14 @@ TEST_F(JsonParser_Variant_Test, True) { verify("false", false); } -TEST_F(JsonParser_Variant_Test, Invalid) { +TEST_F(JsonParser_Variant_Test, OpenBrace) { whenInputIs("{"); resultMustBeInvalid(); } + +TEST_F(JsonParser_Variant_Test, IncompleteStrings) { + verify("\"", ""); + verify("\"hello", "hello"); + verify("\'", ""); + verify("\'world", "world"); +} diff --git a/test/JsonWriter_WriteFloat_Tests.cpp b/test/JsonWriter_WriteFloat_Tests.cpp index 9fa24a30..944bc09a 100644 --- a/test/JsonWriter_WriteFloat_Tests.cpp +++ b/test/JsonWriter_WriteFloat_Tests.cpp @@ -8,8 +8,8 @@ #include #include -#include -#include +#include +#include using namespace ArduinoJson::Internals; diff --git a/test/JsonWriter_WriteString_Tests.cpp b/test/JsonWriter_WriteString_Tests.cpp index c2f1ea17..96ea9cfc 100644 --- a/test/JsonWriter_WriteString_Tests.cpp +++ b/test/JsonWriter_WriteString_Tests.cpp @@ -7,8 +7,8 @@ #include -#include -#include +#include +#include using namespace ArduinoJson::Internals;