file
json.h
Contents
- Reference
Namespaces
Typedefs
- using JsonDocument = rapidjson::Document
- using JsonGenericValue = rapidjson::GenericValue<rapidjson::UTF8<>>
Functions
-
auto parseJsonFile(const std::
string& file) -> JsonDocument - Parse JSON file and return as JsonDocument object.
-
auto parseJsonString(const std::
string& jsonString) -> JsonDocument - Parse JSON string and return as JsonDocument object.
-
auto jsonToString(const JsonDocument& d) -> std::
string - Return string representation of given JsonDocument.
- auto jsonToVec3f(const JsonGenericValue& jsonArray) -> esp::vec3f
- Return Vec3f coordinates representation of given JsonObject of array type.
-
template<typename T>auto jsonIntoVal(CORRADE_
UNUSED const JsonDocument& d, const char* tag, CORRADE_ UNUSED T& val) -> bool - Check passed json doc for existence of passed tag as.
-
template<>auto jsonIntoVal(const JsonDocument& d, const char* tag, float& val) -> bool
- Check passed json doc for existence of passed tag as float. If present, populate passed val with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type.
-
template<>auto jsonIntoVal(const JsonDocument& d, const char* tag, double& val) -> bool
- Check passed json doc for existence of passed tag as double. If present, populate passed val with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type.
-
template<>auto jsonIntoVal(const JsonDocument& d, const char* tag, bool& val) -> bool
- Check passed json doc for existence of passed tag as double. If present, populate passed val with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type.
-
template<>auto jsonIntoVal(const JsonDocument& d, const char* tag, std::
string& val) -> bool - Check passed json doc for existence of passed tag as double. If present, populate passed val with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type.
-
template<>auto jsonIntoVal(const JsonDocument& d, const char* tag, Magnum::
Vector3& val) -> bool - Specialization to handle Magnum::Vector3 values. Check passed json doc for existence of passed tag as Magnum::Vector3. If present, populate passed val with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type.
-
template<typename T>auto jsonIntoSetter(const JsonDocument& d, const char* tag, std::
function<void(T)> setter) -> bool - Check passed json doc for existence of passed jsonTag as value of type T. If present, populate passed setter with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type. Should use explicit type cast on function call if setter is specified using std::bind()
-
template<typename T>auto jsonIntoConstSetter(const JsonDocument& d, const char* tag, std::
function<void(const T)> setter) -> bool - Check passed json doc for existence of passed jsonTag as value of type T, where the consuming setter will treat the value as const. If present, populate passed setter with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type. Should use explicit type cast on function call if setter is specified using std::bind()
-
template<typename GV, typename T>void toVector(const GV& arr, std::
vector<T>* vec, const std:: function<T(const GV&)>& conv) -
template<typename GV>void toIntVector(const GV& value, std::
vector<int>* vec) -
template<typename GV>void toInt64Vector(const GV& value, std::
vector<int64_ t>* vec) -
template<typename GV>void toFloatVector(const GV& value, std::
vector<float>* vec) -
template<typename GV>void toDoubleVector(const GV& value, std::
vector<double>* vec)
Defines
- #define RAPIDJSON_NO_INT64DEFINE
Function documentation
template<typename T>
bool jsonIntoVal(CORRADE_ UNUSED const JsonDocument& d,
const char* tag,
CORRADE_ UNUSED T& val)
Check passed json doc for existence of passed tag as.
Template parameters | |
---|---|
T | type of value to be populated. |
Parameters | |
d | json document to parse |
tag | string tag to look for in json doc |
val | destination value to be populated |
Returns | whether successful or not |
template<>
bool jsonIntoVal(const JsonDocument& d,
const char* tag,
float& val)
Check passed json doc for existence of passed tag as float. If present, populate passed val with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type.
Parameters | |
---|---|
d | json document to parse |
tag | string tag to look for in json doc |
val | destination value to be populated |
Returns | whether successful or not |
template<>
bool jsonIntoVal(const JsonDocument& d,
const char* tag,
double& val)
Check passed json doc for existence of passed tag as double. If present, populate passed val with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type.
Parameters | |
---|---|
d | json document to parse |
tag | string tag to look for in json doc |
val | destination value to be populated |
Returns | whether successful or not |
template<>
bool jsonIntoVal(const JsonDocument& d,
const char* tag,
bool& val)
Check passed json doc for existence of passed tag as double. If present, populate passed val with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type.
Parameters | |
---|---|
d | json document to parse |
tag | string tag to look for in json doc |
val | destination value to be populated |
Returns | whether successful or not |
template<>
bool jsonIntoVal(const JsonDocument& d,
const char* tag,
std:: string& val)
Check passed json doc for existence of passed tag as double. If present, populate passed val with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type.
Parameters | |
---|---|
d | json document to parse |
tag | string tag to look for in json doc |
val | destination value to be populated |
Returns | whether successful or not |
template<>
bool jsonIntoVal(const JsonDocument& d,
const char* tag,
Magnum:: Vector3& val)
Specialization to handle Magnum::Vector3 values. Check passed json doc for existence of passed tag as Magnum::Vector3. If present, populate passed val with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type.
Parameters | |
---|---|
d | json document to parse |
tag | string tag to look for in json doc |
val | destination value to be populated |
Returns | whether successful or not |
template<typename T>
bool jsonIntoSetter(const JsonDocument& d,
const char* tag,
std:: function<void(T)> setter)
Check passed json doc for existence of passed jsonTag as value of type T. If present, populate passed setter with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type. Should use explicit type cast on function call if setter is specified using std::bind()
Template parameters | |
---|---|
T | type of destination variable - must be supported type. |
Parameters | |
d | json document to parse |
tag | string tag to look for in json doc |
setter | value setter in some object to populate with the data from json. |
Returns | whether successful or not |
template<typename T>
bool jsonIntoConstSetter(const JsonDocument& d,
const char* tag,
std:: function<void(const T)> setter)
Check passed json doc for existence of passed jsonTag as value of type T, where the consuming setter will treat the value as const. If present, populate passed setter with value. Returns whether tag is found and successfully populated, or not. Logs an error if tag is found but is inappropriate type. Should use explicit type cast on function call if setter is specified using std::bind()
Template parameters | |
---|---|
T | type of destination variable - must be supported type. |
Parameters | |
d | json document to parse |
tag | string tag to look for in json doc |
setter | value setter in some object to populate with the data from json. |
Returns | whether successful or not |