esp/io/JsonStlTypes.h file

See JsonAllTypes.h. Don't include this header directly in user code.

Namespaces

namespace esp
Root namespace.
namespace esp::io

Functions

auto toJsonValue(const std::string& str, JsonAllocator& allocator) -> JsonGenericValue
auto fromJsonValue(const JsonGenericValue& obj, std::string& val) -> bool
Populate passed val with value. Returns whether successfully populated, or not. Logs an error if inappropriate type.
template<typename T_first, typename T_second>
auto toJsonValue(const std::pair<T_first, T_second>& val, JsonAllocator& allocator) -> JsonGenericValue
template<typename T_first, typename T_second>
auto fromJsonValue(const JsonGenericValue& obj, std::pair<T_first, T_second>& val) -> bool
template<typename T>
void addMember(JsonGenericValue& value, rapidjson::GenericStringRef<char> name, const std::vector<T>& vec, JsonAllocator& allocator)
template<typename T>
auto readMember(const JsonGenericValue& value, const char* tag, std::vector<T>& vec) -> bool
template<>
auto readMember(const JsonGenericValue& d, const char* tag, std::map<std::string, std::string>& val) -> bool
Specialization to handle reading a JSON object into an std::map<std::string, std::string>. Check passed json doc for existence of passed tag and verify it is an object. If present, populate passed val with key-value pairs in cell. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriately configured.
template<>
auto readMember(const JsonGenericValue& d, const char* tag, std::map<std::string, float>& val) -> bool
Specialization to handle reading a JSON object into an std::map<std::string, float>. Check passed json doc for existence of passed tag and verify it is an object. If present, populate passed val with key-value pairs in cell. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriately configured.
template<typename T>
void addMember(JsonGenericValue& value, const rapidjson::GenericStringRef<char>& name, const std::map<std::string, T>& mapVal, JsonAllocator& allocator)
Manage string-keyed map of type T to json Object.

Function documentation

bool fromJsonValue(const JsonGenericValue& obj, std::string& val)

Populate passed val with value. Returns whether successfully populated, or not. Logs an error if inappropriate type.

Parameters
obj json value to parse
val destination value to be populated
Returns whether successful or not

template<>
bool readMember(const JsonGenericValue& d, const char* tag, std::map<std::string, std::string>& val)

Specialization to handle reading a JSON object into an std::map<std::string, std::string>. Check passed json doc for existence of passed tag and verify it is an object. If present, populate passed val with key-value pairs in cell. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriately configured.

Parameters
d json document to parse
tag string tag to look for in json doc
val destination std::map to be populated
Returns whether successful or not

template<>
bool readMember(const JsonGenericValue& d, const char* tag, std::map<std::string, float>& val)

Specialization to handle reading a JSON object into an std::map<std::string, float>. Check passed json doc for existence of passed tag and verify it is an object. If present, populate passed val with key-value pairs in cell. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriately configured.

Parameters
d json document to parse
tag string tag to look for in json doc
val destination std::map to be populated
Returns whether successful or not