Voffcon NodeMcu device server
 All Classes Functions
Json Class Reference

A class for parsing json strings More...

Public Member Functions

 Json (const char *jsonString)
 Parses the json_string into a new JsonData object More...
 
 ~Json ()
 A deconstructor for the Json object. It will free the object from memory. This function fires automatically when this object is no longer needed. More...
 
String toString () const
 Returns the object as a JSON string. This string should be a valid JSON string, ready to be sent over the wire. More...
 
String toTree () const
 Showing objects and sub-objects In a treeview. That is child objects have additional tabs relative to parent objects. More...
 
bool isValid () const
 Will tell you if the current object is invalid More...
 
JsonDatagetRootObject ()
 Use this function access the root JsonData object More...
 

Static Public Member Functions

static String trim (String jsonStringToTrim)
 Removes all unnecessary white spaces like tab end line and carriage return More...
 

Detailed Description

A class for parsing json strings

Example on how to create a json object from a string:

1 Json json("{\"hello\":\"world\",\"array\":[1,2,-4,-5.22,\"string in a array\"]}");

Constructor & Destructor Documentation

Json::Json ( const char *  jsonString)

Parses the json_string into a new JsonData object

// Create an empty object

1 // Create an empty json object
2  JsonData jsEmptyObject("{}");
3 
4 // Create an empty json array
5  JsonData jsEmptyArray("[]");
Parameters
jsonStringMust be a valid JSON string
Json::~Json ( )

A deconstructor for the Json object. It will free the object from memory. This function fires automatically when this object is no longer needed.

Member Function Documentation

JsonData* Json::getRootObject ( )
inline

Use this function access the root JsonData object

Returns
The root JsonData object. If the object is invalid NULL is returned.
bool Json::isValid ( ) const

Will tell you if the current object is invalid

String Json::toString ( ) const

Returns the object as a JSON string. This string should be a valid JSON string, ready to be sent over the wire.

Returns
The current object returned as an JSON String.
String Json::toTree ( ) const

Showing objects and sub-objects In a treeview. That is child objects have additional tabs relative to parent objects.

Returns
The json object as a tree view string.
String Json::trim ( String  jsonStringToTrim)
static

Removes all unnecessary white spaces like tab end line and carriage return

Parameters
jsonStringToTrimThe input string that will be unchanged
Returns
Copy of the input string without all white spaces

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