mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
Reduced memory consumption by not duplicating spaces and comments
This commit is contained in:
@@ -51,58 +51,6 @@ class JsonBuffer {
|
||||
// allocation fails.
|
||||
JsonObject &createObject();
|
||||
|
||||
// Allocates and populate a JsonArray from a JSON string.
|
||||
//
|
||||
// The First argument is a pointer to the JSON string, the memory must be
|
||||
// writable
|
||||
// because the parser will insert null-terminators and replace escaped chars.
|
||||
//
|
||||
// The second argument set the nesting limit
|
||||
//
|
||||
// Returns a reference to the new JsonObject or JsonObject::invalid() if the
|
||||
// allocation fails.
|
||||
JsonArray &parseArray(
|
||||
char *json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT);
|
||||
|
||||
// With this overload, the JsonBuffer will make a copy of the string
|
||||
template <typename TString>
|
||||
JsonArray &parseArray(const TString &json,
|
||||
uint8_t nesting = ARDUINOJSON_DEFAULT_NESTING_LIMIT) {
|
||||
return parseArray(strdup(json), nesting);
|
||||
}
|
||||
|
||||
// Allocates and populate a JsonObject from a JSON string.
|
||||
//
|
||||
// The First argument is a pointer to the JSON string, the memory must be
|
||||
// writable
|
||||
// because the parser will insert null-terminators and replace escaped chars.
|
||||
//
|
||||
// The second argument set the nesting limit
|
||||
//
|
||||
// Returns a reference to the new JsonObject or JsonObject::invalid() if the
|
||||
// allocation fails.
|
||||
JsonObject &parseObject(
|
||||
char *json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT);
|
||||
|
||||
// With this overload, the JsonBuffer will make a copy of the string
|
||||
template <typename TString>
|
||||
JsonObject &parseObject(const TString &json,
|
||||
uint8_t nesting = ARDUINOJSON_DEFAULT_NESTING_LIMIT) {
|
||||
return parseObject(strdup(json), nesting);
|
||||
}
|
||||
|
||||
// Generalized version of parseArray() and parseObject(), also works for
|
||||
// integral types.
|
||||
JsonVariant parse(char *json,
|
||||
uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT);
|
||||
|
||||
// With this overload, the JsonBuffer will make a copy of the string
|
||||
template <typename TString>
|
||||
JsonVariant parse(const TString &json,
|
||||
uint8_t nesting = ARDUINOJSON_DEFAULT_NESTING_LIMIT) {
|
||||
return parse(strdup(json), nesting);
|
||||
}
|
||||
|
||||
// Duplicate a string
|
||||
template <typename TString>
|
||||
char *strdup(const TString &src) {
|
||||
@@ -114,7 +62,7 @@ class JsonBuffer {
|
||||
virtual void *alloc(size_t size) = 0;
|
||||
|
||||
protected:
|
||||
// Preserve aligment if nessary
|
||||
// Preserve aligment if necessary
|
||||
static FORCE_INLINE size_t round_size_up(size_t bytes) {
|
||||
#if ARDUINOJSON_ENABLE_ALIGNMENT
|
||||
const size_t x = sizeof(void *) - 1;
|
||||
|
||||
Reference in New Issue
Block a user