AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
Functions | |
static std::string | getTag () |
bool | findNode (const rapidjson::Value &jsonNode, const std::string &key, rapidjson::Value::ConstMemberIterator *iteratorPtr) |
bool | parseJSON (const std::string &jsonContent, rapidjson::Document *document) |
bool | convertToValue (const rapidjson::Value &documentNode, std::string *value) |
bool | convertToValue (const rapidjson::Value &documentNode, int64_t *value) |
bool | convertToValue (const rapidjson::Value &documentNode, uint64_t *value) |
bool | convertToValue (const rapidjson::Value &documentNode, bool *value) |
bool | convertToValue (const rapidjson::Value &documentNode, double *value) |
template<typename T > | |
bool | retrieveValue (const rapidjson::Value &jsonNode, const std::string &key, T *value) |
template<typename T > | |
bool | retrieveValue (const std::string jsonString, const std::string &key, T *value) |
bool | jsonArrayExists (const rapidjson::Value &parsedDocument, const std::string &key) |
template<class CollectionT > | |
CollectionT | retrieveStringArray (const std::string &jsonString, const std::string &key) |
template<class CollectionT > | |
CollectionT | retrieveStringArray (const std::string &jsonString) |
template<class CollectionT > | |
CollectionT | retrieveStringArray (const rapidjson::Value &value) |
template<class CollectionT > | |
std::string | convertToJsonString (const CollectionT &elements) |
std::map< std::string, std::string > | retrieveStringMap (const rapidjson::Value &value, const std::string &key) |
void | retrieveStringMapFromArray (const rapidjson::Value &value, const std::string &key, std::map< std::string, std::string > &elements) |
bool | retrieveArrayOfStringMapFromArray (const rapidjson::Value &value, const std::string &key, std::vector< std::map< std::string, std::string >> &elements) |
template<> | |
std::vector< std::string > | retrieveStringArray< std::vector< std::string > > (const std::string &jsonString, const std::string &key) |
template<> | |
std::vector< std::string > | retrieveStringArray< std::vector< std::string > > (const std::string &jsonString) |
template<> | |
std::vector< std::string > | retrieveStringArray< std::vector< std::string > > (const rapidjson::Value &value) |
template<> | |
std::string | convertToJsonString< std::vector< std::string > > (const std::vector< std::string > &elements) |
std::string alexaClientSDK::avsCommon::utils::json::jsonUtils::convertToJsonString | ( | const CollectionT & | elements | ) |
Convert a string collection into a JSON string array representation.
elements | A collection that will be converted to the JSON array representation. |
std::string alexaClientSDK::avsCommon::utils::json::jsonUtils::convertToJsonString< std::vector< std::string > > | ( | const std::vector< std::string > & | elements | ) |
bool alexaClientSDK::avsCommon::utils::json::jsonUtils::convertToValue | ( | const rapidjson::Value & | documentNode, |
std::string * | value | ||
) |
Converts a given rapidjson document node to a string. The node must be either of Object or String type.
documentNode | A logical node within a parsed JSON document which rapidjson understands. | |
[out] | value | The output parameter which will be assigned the string value. |
true
If the node was converted to a string ok, false
otherwise. bool alexaClientSDK::avsCommon::utils::json::jsonUtils::convertToValue | ( | const rapidjson::Value & | documentNode, |
int64_t * | value | ||
) |
Converts a given rapidjson value node to a 64-bit signed integer. The node must be Int64 type.
documentNode | A logical node within a parsed JSON document which rapidjson understands. | |
[out] | value | The output parameter which will be assigned the int64_t value. |
true
If the node was successfully converted, false
otherwise. bool alexaClientSDK::avsCommon::utils::json::jsonUtils::convertToValue | ( | const rapidjson::Value & | documentNode, |
uint64_t * | value | ||
) |
Converts a given rapidjson value node to a 64-bit unsigned integer. The node must be unsigned int type.
documentNode | A logical node within a parsed JSON document which rapidjson understands. | |
[out] | value | The output parameter which will be assigned the unsigned int value. |
true
If the node was successfully converted, false
otherwise. bool alexaClientSDK::avsCommon::utils::json::jsonUtils::convertToValue | ( | const rapidjson::Value & | documentNode, |
bool * | value | ||
) |
Converts a given rapidjson value node to a bool. The node must be Bool type.
documentNode | A logical node within a parsed JSON document which rapidjson understands. | |
[out] | value | The output parameter which will be assigned the bool value. |
true
If the node was successfully converted, false
otherwise. bool alexaClientSDK::avsCommon::utils::json::jsonUtils::convertToValue | ( | const rapidjson::Value & | documentNode, |
double * | value | ||
) |
Converts a given rapidjson value node to a double. The node must be double type.
documentNode | A logical node within a parsed JSON document which rapidjson understands. | |
[out] | value | The output parameter which will be assigned the double value. |
true
If the node was successfully converted, false
otherwise. bool alexaClientSDK::avsCommon::utils::json::jsonUtils::findNode | ( | const rapidjson::Value & | jsonNode, |
const std::string & | key, | ||
rapidjson::Value::ConstMemberIterator * | iteratorPtr | ||
) |
Give a rapidjson::Value
object, this function will find a direct child node that matches the key
. Copy constructors are hidden for rapidjson::Value
objects, so iterators are used to retrieve the value of the node.
jsonNode | The JSON node object. | |
key | The key of the underlying JSON content we wish to acquire the value of. | |
[out] | iteratorPtr | A pointer to a ConstMemberIterator , which will contain the Value . |
true
if the lookup is successful, false
otherwise.
|
inlinestatic |
Returns the tag for logging purposes.
bool alexaClientSDK::avsCommon::utils::json::jsonUtils::jsonArrayExists | ( | const rapidjson::Value & | parsedDocument, |
const std::string & | key | ||
) |
Queries whether an array object exists as a child of a pre-parsed rapidjson::Value element.
parsedDocument | The Value within which the array should be looked for. |
key | The name of the array being looked for. |
bool alexaClientSDK::avsCommon::utils::json::jsonUtils::parseJSON | ( | const std::string & | jsonContent, |
rapidjson::Document * | document | ||
) |
Invoke a rapidjson parse on a JSON string.
jsonContent | The JSON content to be parsed. | |
[out] | document | The output parameter rapidjson document. |
true
If the JSON content was valid, false
otherwise. bool alexaClientSDK::avsCommon::utils::json::jsonUtils::retrieveArrayOfStringMapFromArray | ( | const rapidjson::Value & | value, |
const std::string & | key, | ||
std::vector< std::map< std::string, std::string >> & | elements | ||
) |
Retrieve array of string map from array of a rapidjson
value with the given key.
value | A Value that represents a array of string map. |
key | The name of the array being looked for. |
elements | The output collection which will contain all extracted elements. |
CollectionT alexaClientSDK::avsCommon::utils::json::jsonUtils::retrieveStringArray | ( | const std::string & | jsonString, |
const std::string & | key | ||
) |
Find and retrieve a string collection from the provided stringified JSON.
Example:
CollectionT | The collection type. |
jsonString | The input JSON string. |
key | The name of the array being looked for. |
CollectionT alexaClientSDK::avsCommon::utils::json::jsonUtils::retrieveStringArray | ( | const std::string & | jsonString | ) |
Convert a JSON array of strings into a string collection.
jsonString | The input JSON. This should represent the array string not the entire document. E.g.: |
CollectionT alexaClientSDK::avsCommon::utils::json::jsonUtils::retrieveStringArray | ( | const rapidjson::Value & | value | ) |
Retrieve string elements from a rapidjson value.
value | A Value that represents an array of strings. |
std::vector<std::string> alexaClientSDK::avsCommon::utils::json::jsonUtils::retrieveStringArray< std::vector< std::string > > | ( | const std::string & | jsonString, |
const std::string & | key | ||
) |
std::vector<std::string> alexaClientSDK::avsCommon::utils::json::jsonUtils::retrieveStringArray< std::vector< std::string > > | ( | const rapidjson::Value & | value | ) |
std::vector<std::string> alexaClientSDK::avsCommon::utils::json::jsonUtils::retrieveStringArray< std::vector< std::string > > | ( | const std::string & | jsonString | ) |
std::map<std::string, std::string> alexaClientSDK::avsCommon::utils::json::jsonUtils::retrieveStringMap | ( | const rapidjson::Value & | value, |
const std::string & | key | ||
) |
Retrieve a string map from a rapidjson
value with the given key.
value | A Value that represents a string map. |
key | The name of the array being looked for. |
void alexaClientSDK::avsCommon::utils::json::jsonUtils::retrieveStringMapFromArray | ( | const rapidjson::Value & | value, |
const std::string & | key, | ||
std::map< std::string, std::string > & | elements | ||
) |
Retrieve string map from array of a rapidjson
value with the given key.
value | A Value that represents a array of string map. |
key | The name of the array being looked for. |
elements | The output collection which will contain all extracted elements. An empty collection if value contains non-string elements or if the key was not found. |
bool alexaClientSDK::avsCommon::utils::json::jsonUtils::retrieveValue | ( | const rapidjson::Value & | jsonNode, |
const std::string & | key, | ||
T * | value | ||
) |
A template function to find and retrieve a value of type T from a direct child of the provided rapidjson::Value
object. The type T must have an overload of the function convertToValue
.
jsonNode | A logical node within a parsed JSON document which rapidjson understands. | |
key | The key in which to look for the value. | |
[out] | value | The output parameter which will be assigned the value of type T if the function succeeds. No modification is done in case of failure. |
true
If the value was successfully retrieved, false
otherwise. bool alexaClientSDK::avsCommon::utils::json::jsonUtils::retrieveValue | ( | const std::string | jsonString, |
const std::string & | key, | ||
T * | value | ||
) |
A template function to find and retrieve a value of type T from the provided JSON string. The provided string will first be parsed into a JSON document, after which the associated value T will be retrieved. The type T must have an overload of the function convertToValue
.
jsonString | A JSON string. | |
key | The key in which to look for the value. | |
[out] | value | The output parameter which will be assigned the value of type T if the function succeeds. No modification is done in case of failure. |
true
If the value was successfully retrieved, false
otherwise. AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0