cesium-native 0.43.0
|
A collection of helper functions to make reading JSON simpler. More...
#include <CesiumUtility/JsonHelpers.h>
Static Public Member Functions | |
static std::optional< double > | getScalarProperty (const rapidjson::Value &tileJson, const std::string &key) |
Attempts to read the value at key of tileJson as a double , returning std::nullopt if it wasn't found or couldn't be read as a double. | |
static std::optional< glm::dmat4x4 > | getTransformProperty (const rapidjson::Value &tileJson, const std::string &key) |
Attempts to read the value at key of tileJson as a glm::dmat4x4 , returning std::nullopt if it wasn't found or couldn't be read as a glm::dmat4x4. | |
static std::optional< std::vector< double > > | getDoubles (const rapidjson::Value &json, int32_t expectedSize, const std::string &key) |
Obtains an array of numbers from the given JSON. | |
static std::string | getStringOrDefault (const rapidjson::Value &json, const std::string &key, const std::string &defaultValue) |
Attempts to obtain a string from the given key on the JSON object, returning a default value if this isn't possible. | |
static std::string | getStringOrDefault (const rapidjson::Value &json, const std::string &defaultValue) |
Attempts to read json as a string, returning a default value if this isn't possible. | |
static double | getDoubleOrDefault (const rapidjson::Value &json, const std::string &key, double defaultValue) |
Attempts to obtain a double from the given key on the JSON object, returning a default value if this isn't possible. | |
static double | getDoubleOrDefault (const rapidjson::Value &json, double defaultValue) |
Attempts to read json as a double, returning a default value if this isn't possible. | |
static uint32_t | getUint32OrDefault (const rapidjson::Value &json, const std::string &key, uint32_t defaultValue) |
Attempts to obtain a uint32_t from the given key on the JSON object, returning a default value if this isn't possible. | |
static uint32_t | getUint32OrDefault (const rapidjson::Value &json, uint32_t defaultValue) |
Attempts to read json as a uint32_t, returning a default value if this isn't possible. | |
static int32_t | getInt32OrDefault (const rapidjson::Value &json, const std::string &key, int32_t defaultValue) |
Attempts to obtain a int32_t from the given key on the JSON object, returning a default value if this isn't possible. | |
static int32_t | getInt32OrDefault (const rapidjson::Value &json, int32_t defaultValue) |
Attempts to read json as a int32_t, returning a default value if this isn't possible. | |
static uint64_t | getUint64OrDefault (const rapidjson::Value &json, const std::string &key, uint64_t defaultValue) |
Attempts to obtain a uint64_t from the given key on the JSON object, returning a default value if this isn't possible. | |
static uint64_t | getUint64OrDefault (const rapidjson::Value &json, uint64_t defaultValue) |
Attempts to read json as a uint64_t, returning a default value if this isn't possible. | |
static int64_t | getInt64OrDefault (const rapidjson::Value &json, const std::string &key, int64_t defaultValue) |
Attempts to obtain a int64_t from the given key on the JSON object, returning a default value if this isn't possible. | |
static int64_t | getInt64OrDefault (const rapidjson::Value &json, int64_t defaultValue) |
Attempts to read json as a int64_t, returning a default value if this isn't possible. | |
static bool | getBoolOrDefault (const rapidjson::Value &json, const std::string &key, bool defaultValue) |
Attempts to obtain a bool from the given key on the JSON object, returning a default value if this isn't possible. | |
static bool | getBoolOrDefault (const rapidjson::Value &json, bool defaultValue) |
Attempts to read json as a bool, returning a default value if this isn't possible. | |
static std::vector< std::string > | getStrings (const rapidjson::Value &json, const std::string &key) |
Attempts to read an array of strings from the property key of json , returning an empty vector if this isn't possible. | |
static std::vector< int64_t > | getInt64s (const rapidjson::Value &json, const std::string &key) |
Attempts to read an int64_t array from the property key of json , returning an empty vector if this isn't possible. | |
A collection of helper functions to make reading JSON simpler.
Definition at line 15 of file JsonHelpers.h.
|
static |
Attempts to read json
as a bool, returning a default value if this isn't possible.
json | The JSON value that might be a bool. |
defaultValue | The default value to return if json couldn't be read as a bool. |
|
static |
Attempts to obtain a bool from the given key on the JSON object, returning a default value if this isn't possible.
json | The JSON object. |
key | The key (property name) of the bool. |
defaultValue | The default value to return if the bool property key of json couldn't be read. |
|
static |
Attempts to obtain a double from the given key on the JSON object, returning a default value if this isn't possible.
json | The JSON object. |
key | The key (property name) of the double. |
defaultValue | The default value to return if the double property key of json couldn't be read. |
|
static |
Attempts to read json
as a double, returning a default value if this isn't possible.
json | The JSON value that might be a double. |
defaultValue | The default value to return if json couldn't be read as a double. |
|
static |
Obtains an array of numbers from the given JSON.
If the property is not found, or is not an array, or does contain elements that are not numbers, then std::nullopt
is returned.
If the given expected size is not negative, and the actual size of the array does not match the expected size, then nullopt
is returned.
json | The JSON object. |
expectedSize | The expected size of the array. |
key | The key (property name) of the array. |
nullopt
.
|
static |
Attempts to obtain a int32_t from the given key on the JSON object, returning a default value if this isn't possible.
json | The JSON object. |
key | The key (property name) of the int32_t. |
defaultValue | The default value to return if the int32_t property key of json couldn't be read. |
|
static |
Attempts to read json
as a int32_t, returning a default value if this isn't possible.
json | The JSON value that might be a int32_t. |
defaultValue | The default value to return if json couldn't be read as a int32_t. |
|
static |
Attempts to obtain a int64_t from the given key on the JSON object, returning a default value if this isn't possible.
json | The JSON object. |
key | The key (property name) of the int64_t. |
defaultValue | The default value to return if the int64_t property key of json couldn't be read. |
|
static |
Attempts to read json
as a int64_t, returning a default value if this isn't possible.
json | The JSON value that might be a int64_t. |
defaultValue | The default value to return if json couldn't be read as a int64_t. |
|
static |
Attempts to read an int64_t array from the property key
of json
, returning an empty vector if this isn't possible.
json | The JSON object. |
key | The key (property name) of the int64_t array. |
|
static |
Attempts to read the value at key
of tileJson
as a double
, returning std::nullopt if it wasn't found or couldn't be read as a double.
tileJson | The JSON object to obtain the scalar property from. |
key | The key of the scalar property to obtain. |
|
static |
Attempts to read json
as a string, returning a default value if this isn't possible.
json | The JSON value that might be a string. |
defaultValue | The default value to return if json couldn't be read as a string. |
|
static |
Attempts to obtain a string from the given key on the JSON object, returning a default value if this isn't possible.
json | The JSON object. |
key | The key (property name) of the string. |
defaultValue | The default value to return if the string property key of json couldn't be read. |
|
static |
Attempts to read an array of strings from the property key
of json
, returning an empty vector if this isn't possible.
json | The JSON object. |
key | The key (property name) of the string array. |
|
static |
Attempts to read the value at key
of tileJson
as a glm::dmat4x4
, returning std::nullopt if it wasn't found or couldn't be read as a glm::dmat4x4.
tileJson | The JSON object to obtain the transform property from. |
key | The key of the transform property. |
|
static |
Attempts to obtain a uint32_t from the given key on the JSON object, returning a default value if this isn't possible.
json | The JSON object. |
key | The key (property name) of the uint32_t. |
defaultValue | The default value to return if the uint32_t property key of json couldn't be read. |
|
static |
Attempts to read json
as a uint32_t, returning a default value if this isn't possible.
json | The JSON value that might be a uint32_t. |
defaultValue | The default value to return if json couldn't be read as a uint32_t. |
|
static |
Attempts to obtain a uint64_t from the given key on the JSON object, returning a default value if this isn't possible.
json | The JSON object. |
key | The key (property name) of the uint64_t. |
defaultValue | The default value to return if the uint64_t property key of json couldn't be read. |
|
static |
Attempts to read json
as a uint64_t, returning a default value if this isn't possible.
json | The JSON value that might be a uint64_t. |
defaultValue | The default value to return if json couldn't be read as a uint64_t. |