SensESP
3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
json.h
Go to the documentation of this file.
1
#ifndef SENSESP_SRC_SENSESP_TYPES_JSON_H_
2
#define SENSESP_SRC_SENSESP_TYPES_JSON_H_
3
4
#include <vector>
5
6
#include "ArduinoJson.h"
7
8
namespace
ArduinoJson
{
9
template
<
typename
T>
10
struct
Converter<std::vector<T> > {
11
static
void
toJson
(
const
std::vector<T>& src, JsonVariant dst) {
12
JsonArray array = dst.to<JsonArray>();
13
for
(T item : src) array.add(item);
14
}
15
16
static
std::vector<T>
fromJson
(JsonVariantConst src) {
17
std::vector<T> dst;
18
for
(T item : src.as<JsonArrayConst>()) dst.push_back(item);
19
return
dst;
20
}
21
22
static
bool
checkJson
(JsonVariantConst src) {
23
JsonArrayConst array = src;
24
bool
result = array;
25
for
(JsonVariantConst item : array) result &= item.is<T>();
26
return
result;
27
}
28
};
29
}
// namespace ARDUINOJSON_NAMESPACE
30
31
#endif
// SENSESP_SRC_SENSESP_TYPES_JSON_H_
ArduinoJson
Definition
json.h:8
ArduinoJson::Converter< std::vector< T > >::toJson
static void toJson(const std::vector< T > &src, JsonVariant dst)
Definition
json.h:11
ArduinoJson::Converter< std::vector< T > >::checkJson
static bool checkJson(JsonVariantConst src)
Definition
json.h:22
ArduinoJson::Converter< std::vector< T > >::fromJson
static std::vector< T > fromJson(JsonVariantConst src)
Definition
json.h:16
src
sensesp
types
json.h
Generated by
1.12.0