mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	README: added a link to ARDUINOJSON_ENABLE_ARDUINO_STREAM
This commit is contained in:
		| @@ -34,8 +34,8 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). | |||||||
|     * Deduplicates strings |     * Deduplicates strings | ||||||
| * Versatile | * Versatile | ||||||
|     * [Supports custom allocators (to use external RAM chip, for example)](https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/?utm_source=github&utm_medium=readme) |     * [Supports custom allocators (to use external RAM chip, for example)](https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/?utm_source=github&utm_medium=readme) | ||||||
|     * Supports [Arduino's `String`](https://arduinojson.org/v6/api/config/enable_arduino_string/) and [STL's `std::string`](https://arduinojson.org/v6/api/config/enable_std_string/?utm_source=github&utm_medium=readme) |     * Supports [Arduino's `String`](https://arduinojson.org/v6/api/config/enable_arduino_string/?utm_source=github&utm_medium=readme) and [STL's `std::string`](https://arduinojson.org/v6/api/config/enable_std_string/?utm_source=github&utm_medium=readme) | ||||||
|     * Supports Arduino's `Stream` and [STL's `std::istream`/`std::ostream`](https://arduinojson.org/v6/api/config/enable_std_stream/?utm_source=github&utm_medium=readme) |     * Supports [Arduino's `Stream`](https://arduinojson.org/v6/api/config/enable_arduino_stream/?utm_source=github&utm_medium=readme) and [STL's `std::istream`/`std::ostream`](https://arduinojson.org/v6/api/config/enable_std_stream/?utm_source=github&utm_medium=readme) | ||||||
|     * [Supports Flash strings](https://arduinojson.org/v6/api/config/enable_progmem/?utm_source=github&utm_medium=readme) |     * [Supports Flash strings](https://arduinojson.org/v6/api/config/enable_progmem/?utm_source=github&utm_medium=readme) | ||||||
|     * Supports [custom readers](https://arduinojson.org/v6/api/json/deserializejson/?utm_source=github&utm_medium=readme#custom-reader) and [custom writers](https://arduinojson.org/v6/api/json/serializejson/?utm_source=github&utm_medium=readme#custom-writer) |     * Supports [custom readers](https://arduinojson.org/v6/api/json/deserializejson/?utm_source=github&utm_medium=readme#custom-reader) and [custom writers](https://arduinojson.org/v6/api/json/serializejson/?utm_source=github&utm_medium=readme#custom-writer) | ||||||
|     * Supports custom converters |     * Supports custom converters | ||||||
| @@ -87,7 +87,7 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). | |||||||
|     * [How-tos](https://arduinojson.org/v6/example/?utm_source=github&utm_medium=readme) |     * [How-tos](https://arduinojson.org/v6/example/?utm_source=github&utm_medium=readme) | ||||||
|     * [FAQ](https://arduinojson.org/v6/faq/?utm_source=github&utm_medium=readme) |     * [FAQ](https://arduinojson.org/v6/faq/?utm_source=github&utm_medium=readme) | ||||||
|     * [Book](https://arduinojson.org/book/?utm_source=github&utm_medium=readme) |     * [Book](https://arduinojson.org/book/?utm_source=github&utm_medium=readme) | ||||||
|     * [Changelog](changelog.md) |     * [Changelog](CHANGELOG.md) | ||||||
| * Vibrant user community | * Vibrant user community | ||||||
|     * Most popular of all Arduino libraries on [GitHub](https://github.com/search?o=desc&q=arduino+library&s=stars&type=Repositories) and [PlatformIO](https://platformio.org/lib/search) |     * Most popular of all Arduino libraries on [GitHub](https://github.com/search?o=desc&q=arduino+library&s=stars&type=Repositories) and [PlatformIO](https://platformio.org/lib/search) | ||||||
|     * [Used in hundreds of projects](https://www.hackster.io/search?i=projects&q=arduinojson) |     * [Used in hundreds of projects](https://www.hackster.io/search?i=projects&q=arduinojson) | ||||||
|   | |||||||
| @@ -263,7 +263,7 @@ inline bool convertToJson(VariantRef variant, const ::Printable& value) { | |||||||
|     data->setNull(); |     data->setNull(); | ||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
|   data->setOwnedString(print.c_str()); |   data->setStringPointer(print.c_str(), storage_policies::store_by_copy()); | ||||||
|   return true; |   return true; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -244,64 +244,21 @@ class VariantData { | |||||||
|     setType(VALUE_IS_NULL); |     setType(VALUE_IS_NULL); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void setOwnedString(const char *s) { |   void setStringPointer(const char *s, storage_policies::store_by_copy) { | ||||||
|     ARDUINOJSON_ASSERT(s != 0); |     ARDUINOJSON_ASSERT(s != 0); | ||||||
|     setType(VALUE_IS_OWNED_STRING); |     setType(VALUE_IS_OWNED_STRING); | ||||||
|     _content.asString = s; |     _content.asString = s; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void setLinkedString(const char *s) { |   void setStringPointer(const char *s, storage_policies::store_by_address) { | ||||||
|     ARDUINOJSON_ASSERT(s != 0); |     ARDUINOJSON_ASSERT(s != 0); | ||||||
|     setType(VALUE_IS_LINKED_STRING); |     setType(VALUE_IS_LINKED_STRING); | ||||||
|     _content.asString = s; |     _content.asString = s; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void setStringPointer(const char *s, storage_policies::store_by_copy) { |  | ||||||
|     setOwnedString(s); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   void setStringPointer(const char *s, storage_policies::store_by_address) { |  | ||||||
|     setLinkedString(s); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   template <typename TAdaptedString> |   template <typename TAdaptedString> | ||||||
|   bool setString(TAdaptedString value, MemoryPool *pool) { |   bool setString(TAdaptedString value, MemoryPool *pool) { | ||||||
|     return setString(value, pool, typename TAdaptedString::storage_policy()); |     return storeString(value, pool, typename TAdaptedString::storage_policy()); | ||||||
|   } |  | ||||||
|  |  | ||||||
|   template <typename TAdaptedString> |  | ||||||
|   inline bool setString(TAdaptedString value, MemoryPool *pool, |  | ||||||
|                         storage_policies::decide_at_runtime) { |  | ||||||
|     if (value.isStatic()) |  | ||||||
|       return setString(value, pool, storage_policies::store_by_address()); |  | ||||||
|     else |  | ||||||
|       return setString(value, pool, storage_policies::store_by_copy()); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   template <typename TAdaptedString> |  | ||||||
|   inline bool setString(TAdaptedString value, MemoryPool *, |  | ||||||
|                         storage_policies::store_by_address) { |  | ||||||
|     if (value.isNull()) |  | ||||||
|       setNull(); |  | ||||||
|     else |  | ||||||
|       setStringPointer(value.data(), storage_policies::store_by_address()); |  | ||||||
|     return true; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   template <typename TAdaptedString> |  | ||||||
|   inline bool setString(TAdaptedString value, MemoryPool *pool, |  | ||||||
|                         storage_policies::store_by_copy) { |  | ||||||
|     if (value.isNull()) { |  | ||||||
|       setNull(); |  | ||||||
|       return true; |  | ||||||
|     } |  | ||||||
|     const char *copy = pool->saveString(value); |  | ||||||
|     if (!copy) { |  | ||||||
|       setNull(); |  | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|     setStringPointer(copy, storage_policies::store_by_copy()); |  | ||||||
|     return true; |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   CollectionData &toArray() { |   CollectionData &toArray() { | ||||||
| @@ -388,6 +345,41 @@ class VariantData { | |||||||
|     _flags &= KEY_IS_OWNED; |     _flags &= KEY_IS_OWNED; | ||||||
|     _flags |= t; |     _flags |= t; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   template <typename TAdaptedString> | ||||||
|  |   inline bool storeString(TAdaptedString value, MemoryPool *pool, | ||||||
|  |                           storage_policies::decide_at_runtime) { | ||||||
|  |     if (value.isStatic()) | ||||||
|  |       return storeString(value, pool, storage_policies::store_by_address()); | ||||||
|  |     else | ||||||
|  |       return storeString(value, pool, storage_policies::store_by_copy()); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   template <typename TAdaptedString> | ||||||
|  |   inline bool storeString(TAdaptedString value, MemoryPool *, | ||||||
|  |                           storage_policies::store_by_address) { | ||||||
|  |     if (value.isNull()) | ||||||
|  |       setNull(); | ||||||
|  |     else | ||||||
|  |       setStringPointer(value.data(), storage_policies::store_by_address()); | ||||||
|  |     return true; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   template <typename TAdaptedString> | ||||||
|  |   inline bool storeString(TAdaptedString value, MemoryPool *pool, | ||||||
|  |                           storage_policies::store_by_copy) { | ||||||
|  |     if (value.isNull()) { | ||||||
|  |       setNull(); | ||||||
|  |       return true; | ||||||
|  |     } | ||||||
|  |     const char *copy = pool->saveString(value); | ||||||
|  |     if (!copy) { | ||||||
|  |       setNull(); | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  |     setStringPointer(copy, storage_policies::store_by_copy()); | ||||||
|  |     return true; | ||||||
|  |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user