RDK Documentation (Open Sourced RDK Components)
AampJsonObject Class Reference

Utility class to construct a JSON string. More...

#include <AampJsonObject.h>

Inheritance diagram for AampJsonObject:
Inheritance graph
Collaboration diagram for AampJsonObject:
Collaboration graph

Public Types

enum  ENCODING
 

Public Member Functions

 AampJsonObject (const std::string &jsonStr)
 
 AampJsonObject (const char *jsonStr)
 
 AampJsonObject (const AampJsonObject &)=delete
 
AampJsonObjectoperator= (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
 
AampJsonObjectmParent
 

yes

Utility class to construct a JSON string.

Definition at line 37 of file AampJsonObject.h.

Member Enumeration Documentation

◆ ENCODING

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.

Member Function Documentation

◆ print()

std::string AampJsonObject::print ( )

Print the constructed JSON to a string.

Returns
JSON string
Parameters
[out]data- vector to output printed JSON to
Returns
void.

Definition at line 365 of file AampJsonObject.cpp.

◆ print_UnFormatted()

std::string AampJsonObject::print_UnFormatted ( )

Print the constructed JSON to a string.

Returns
JSON string

Definition at line 380 of file AampJsonObject.cpp.

◆ isArray()

bool AampJsonObject::isArray ( const std::string &  name)

Check whether the value is Array or not.

Returns
true if it is Array or false

Definition at line 404 of file AampJsonObject.cpp.

◆ isString()

bool AampJsonObject::isString ( const std::string &  name)

Check whether the value is String or not.

Returns
true if it is String or false

Definition at line 418 of file AampJsonObject.cpp.

◆ isNumber()

bool AampJsonObject::isNumber ( const std::string &  name)

Check whether the value is Number or not.

Returns
true if it is Number or false

Definition at line 432 of file AampJsonObject.cpp.

◆ isObject()

bool AampJsonObject::isObject ( const std::string &  name)

Check whether the value is Object or not.

Returns
true if it is Object or false

Definition at line 446 of file AampJsonObject.cpp.


The documentation for this class was generated from the following files: