1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-25 20:18:15 +00:00
Jesse Hills 95e45dc12c
Allow parse_json to return a boolean result (#6884)
* Allow parse_json to return a boolean result

* Remove pass variable
2024-06-10 22:40:56 +00:00

30 lines
755 B
C++

#pragma once
#include <vector>
#include "esphome/core/helpers.h"
#define ARDUINOJSON_ENABLE_STD_STRING 1 // NOLINT
#define ARDUINOJSON_USE_LONG_LONG 1 // NOLINT
#include <ArduinoJson.h>
namespace esphome {
namespace json {
/// Callback function typedef for parsing JsonObjects.
using json_parse_t = std::function<bool(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.
bool parse_json(const std::string &data, const json_parse_t &f);
} // namespace json
} // namespace esphome