ESPHome  2024.11.0
json_util.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 
5 #include "esphome/core/helpers.h"
6 
7 #define ARDUINOJSON_ENABLE_STD_STRING 1 // NOLINT
8 
9 #define ARDUINOJSON_USE_LONG_LONG 1 // NOLINT
10 
11 #include <ArduinoJson.h>
12 
13 namespace esphome {
14 namespace json {
15 
17 using json_parse_t = std::function<bool(JsonObject)>;
18 
20 using json_build_t = std::function<void(JsonObject)>;
21 
23 std::string build_json(const json_build_t &f);
24 
26 bool parse_json(const std::string &data, const json_parse_t &f);
27 
28 } // namespace json
29 } // namespace esphome
bool parse_json(const std::string &data, const json_parse_t &f)
Parse a JSON string and run the provided json parse function if it&#39;s valid.
Definition: json_util.cpp:65
std::function< void(JsonObject)> json_build_t
Callback function typedef for building JsonObjects.
Definition: json_util.h:20
std::function< bool(JsonObject)> json_parse_t
Callback function typedef for parsing JsonObjects.
Definition: json_util.h:17
std::string build_json(const json_build_t &f)
Build a JSON string with the provided json build function.
Definition: json_util.cpp:21
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7