WaOVJson
Description |
Represents the JSON data structure. |
Important public methods of this class are:
Name |
Return type |
Description |
WaOVJson |
|
The constructor of this class. The type of the JSON can be NUMBER, STRING, BOOL, OBJECT, ARRAY, EMPTY (also known as NULL) or UNDEFINED. The default constructor creates an instance with UNDEFINED type. Other constructors infer the JSON type from the parameters. |
toString |
wstring |
Returns the string representation of the JSON. |
getType |
JsonTypeEnum |
Returns the type of this JSON. JSON type can be NUMBER, STRING, BOOL, OBJECT, ARRAY, EMPTY (also known as NULL) or UNDEFINED. |
setType |
void |
Resets the type of this JSON. JSON type can be NUMBER, STRING, BOOL, OBJECT, ARRAY, EMPTY (also known as NULL) or UNDEFINED. |
getValue |
bool |
Gets the value of a field in the JSON of OBJECT type based on the name of the field. Returns true if the method can get the value successfully and false otherwise. |
getValueAsString |
bool |
Gets the string value of the JSON of STRING type. This method returns true if it can get the value successfully and false otherwise. |
getValueAsInt |
bool |
Gets the integer value of the JSON of NUMBER type. This method returns true if it can get the value successfully and false otherwise. |
containsKey |
bool |
Returns true if the JSON is of OBJECT type and contains a key with the name passed in and false otherwise. |
getKeys |
list<wstring> |
Returns the list of keys of the JSON if it is of OBJECT type and an empty list if it is not. |
putToObject |
bool |
Puts a (key, JSON value) to the instance of OBJECT type. If the instance's type is not OBJECT, this method resets the instance, set its type to OBJECT and add the (key, value) pair to it. This method always returns true. |
addToArray |
bool |
Adds a JSON value in the instance of ARRAY type. If the instance's type is not ARRAY, this method resets the instance, set its type to ARRAY and add the JSON value into it. This method always returns true. |
getArraySize |
int |
Returns the number of items in the instance of ARRAY type. It returns -1 if the instance's type is not ARRAY. |