This arduino library is based on libyaml.
It provides several ways to convert YAML<=>JSON using libyaml, cJSON or ArduinoJson objects.
Supported platforms (some untested):
- ESP32
- RP2040
- ESP8266
- SAMD
#include <ArduinoYaml.h>
or
#include <YAMLDuino.h>
YAML is a superset of JSON, so native conversion from JSON is possible without any additional JSON library.
#include <ArduinoYaml.h>
// JSON stream to YAML stream
size_t serializeYml( Stream &json_src_stream, Stream &yml_dest_stream );
#include <ArduinoJson.h> // include this first or functions will be disabled
#include <ArduinoYaml.h>
// ArduinoJSON object to YAML string
size_t serializeYml( JsonVariant src_obj, String &dest_string );
// ArduinoJSON object to YAML stream
size_t serializeYml( JsonVariant src_obj, Stream &dest_stream );
// Deserialize YAML string to ArduinoJSON object
DeserializationError deserializeYml( JsonObject &dest_obj, const char* src_yaml_str );
// Deserialize YAML stream to ArduinoJSON object
DeserializationError deserializeYml( JsonObject &dest_obj, Stream &src_stream );
// Deserialize YAML string to ArduinoJSON document
DeserializationError deserializeYml( JsonDocument &dest_doc, Stream &src_stream );
// Deserialize YAML string to ArduinoJSON document
DeserializationError deserializeYml( JsonDocument &dest_doc, const char *src_yaml_str) ;
// #include <cJSON.h> // no need to include, cJSON is built-in with esp32 and also bundled with ArduinoYaml
#include <ArduinoYaml.h>
// cJSON object to YAML string
size_t serializeYml( cJSON* src_obj, String &dest_string );
// cJSON object to YAML stream
size_t serializeYml( cJSON* src_obj, Stream &dest_stream );
// YAML string to cJSON object
int deserializeYml( cJSON* dest_obj, const char* src_yaml_str );
// YAML stream to cJSON object
int deserializeYml( cJSON* dest_obj, Stream &src_stream );
- ArduinoJson : https://github.com/bblanchon/ArduinoJson
- cJSON : https://github.com/DaveGamble/cJSON
- libyaml : https://github.com/yaml/libyaml