mirror of https://github.com/esphome/esphome.git
29 lines
744 B
C++
29 lines
744 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
#include "esphome/core/helpers.h"
|
|
|
|
#undef ARDUINOJSON_ENABLE_STD_STRING
|
|
#define ARDUINOJSON_ENABLE_STD_STRING 1 // NOLINT
|
|
|
|
#include <ArduinoJson.h>
|
|
|
|
namespace esphome {
|
|
namespace json {
|
|
|
|
/// Callback function typedef for parsing JsonObjects.
|
|
using json_parse_t = std::function<void(JsonObject)>;
|
|
|
|
/// Callback function typedef for building JsonObjects.
|
|
using json_build_t = std::function<void(JsonObject)>;
|
|
|
|
/// Build a JSON string with the provided json build function.
|
|
std::string build_json(const json_build_t &f);
|
|
|
|
/// Parse a JSON string and run the provided json parse function if it's valid.
|
|
void parse_json(const std::string &data, const json_parse_t &f);
|
|
|
|
} // namespace json
|
|
} // namespace esphome
|