![]() |
RDK Documentation (Open Sourced RDK Components)
|
Utility class to construct a JSON string. More...
#include <AampJsonObject.h>


Public Types | |
| enum | ENCODING |
Public Member Functions | |
| AampJsonObject (const std::string &jsonStr) | |
| AampJsonObject (const char *jsonStr) | |
| AampJsonObject (const AampJsonObject &)=delete | |
| AampJsonObject & | operator= (const AampJsonObject &)=delete |
| bool | add (const std::string &name, const std::string &value, const ENCODING encoding=ENCODING_STRING) |
| Add a string value. | |
| bool | add (const std::string &name, const char *value, const ENCODING encoding=ENCODING_STRING) |
| Add a string value. | |
| bool | add (const std::string &name, const std::vector< std::string > &values) |
| Add a vector of string values as a JSON array. | |
| bool | add (const std::string &name, const std::vector< uint8_t > &values, const ENCODING encoding=ENCODING_STRING) |
| Add the provided bytes after encoding in the specified encoding. | |
| bool | add (const std::string &name, std::vector< AampJsonObject * > &values) |
| Add a vector of string values as a JSON array. | |
| bool | get (const std::string &name, std::vector< std::string > &values) |
| Get a string value. | |
| bool | get (const std::string &name, int &value) |
| Get a int value from a JSON data. | |
| bool | get (const std::string &name, std::string &value) |
| Get a string value. | |
| bool | get (const std::string &name, std::vector< uint8_t > &values, const ENCODING encoding=ENCODING_STRING) |
| Get a string value as a vector of bytes. | |
| bool | get (const std::string &name, AampJsonObject &value) |
| Get the AampJson object from json data within the Json data. | |
| std::string | print () |
| Print the constructed JSON to a string. More... | |
| std::string | print_UnFormatted () |
| Print the constructed JSON to a string. More... | |
| void | print (std::vector< uint8_t > &data) |
| Print the constructed JSON into the provided vector. | |
| bool | add (const std::string &name, bool value) |
| Add a bool value. | |
| bool | add (const std::string &name, int value) |
| Add a int value. | |
| bool | add (const std::string &name, double value) |
| Add a double value. | |
| bool | add (const std::string &name, long value) |
| Add a long value. | |
| bool | add (const std::string &name, AampJsonObject &value) |
| Add a vector of AampJsonObject as a JSON array. | |
| bool | add (const std::string &name, cJSON *value) |
| Add a cJSON value. | |
| bool | isArray (const std::string &name) |
| Check whether the value is Array or not. More... | |
| bool | isString (const std::string &name) |
| Check whether the value is String or not. More... | |
| bool | isNumber (const std::string &name) |
| Check whether the value is Number or not. More... | |
| bool | isObject (const std::string &name) |
| Check whether the value is Object or not. More... | |
Private Member Functions | |
| bool | set (AampJsonObject *parent, cJSON *object) |
| Set cJSON value. | |
| bool | add (const std::string &name) |
Private Attributes | |
| cJSON * | mJsonObj |
| AampJsonObject * | mParent |
Utility class to construct a JSON string.
Definition at line 37 of file AampJsonObject.h.
| Enumerator | |
|---|---|
| ENCODING_STRING | Bytes encoded as a string as-is |
| ENCODING_BASE64 | Bytes base64 encoded to a string |
| ENCODING_BASE64_URL | Bytes base64url encoded to a string |
Definition at line 46 of file AampJsonObject.h.
| std::string AampJsonObject::print | ( | ) |
Print the constructed JSON to a string.
| [out] | data | - vector to output printed JSON to |
Definition at line 365 of file AampJsonObject.cpp.
| std::string AampJsonObject::print_UnFormatted | ( | ) |
Print the constructed JSON to a string.
Definition at line 380 of file AampJsonObject.cpp.
| bool AampJsonObject::isArray | ( | const std::string & | name | ) |
Check whether the value is Array or not.
Definition at line 404 of file AampJsonObject.cpp.
| bool AampJsonObject::isString | ( | const std::string & | name | ) |
Check whether the value is String or not.
Definition at line 418 of file AampJsonObject.cpp.
| bool AampJsonObject::isNumber | ( | const std::string & | name | ) |
Check whether the value is Number or not.
Definition at line 432 of file AampJsonObject.cpp.
| bool AampJsonObject::isObject | ( | const std::string & | name | ) |
Check whether the value is Object or not.
Definition at line 446 of file AampJsonObject.cpp.