NetBurner 3.5.0
PDF Version
 
ParsedJsonDataSet Class Reference

A class to create, read, and modify a JSON object. More...

#include <json_lexer.h>

Inherits buffer_object.

Inherited by AcmeJsonBuffer, AcmeServletBuffer, and JsonLexerFDAdapter.

Public Member Functions

Parsing

Ingesting raw JSON data from some source, or resetting. Enables compatibility with buffer_object and WebClient.

void EnableLargeStrings (bool b)
 Call to allow allocation of strings larger than 1500 bytes.
 
virtual int WriteData (const unsigned char *pCopyFrom, int numBytes)
 Writes the passed in data to the JSON data set.
 
virtual int ReadFrom (int fd)
 Reads in data from the specified file descriptor and parses it into the JSON data set.
 
bool CopyObject (ParsedJsonDataSet &src_set)
 Copies the provided JSON data set into the current one.
 
void ClearObject ()
 Clears all data from the object and resets it to its initial state.
 
Querying the Data Structure

Allows easy retrieval of entities by array index or object key name

Example
printf("User %d name %s",
(int)myJsonRef("users")[0]("id"),
(const char *)myJsonRef("users")[0]("name")
);
JsonRef operator[] (int i)
 Get a JsonRef from an array by numerical index.
 
JsonRef operator() (const char *name)
 Get a JsonRef representing any entity from a parent object by key name.
 
JsonRef name (const char *name)
 Get a JsonRef representing any entity from a parent object by key name.
 
JsonRef object (const char *name)
 Get a JsonRef representing an object from a parent object by key name.
 
Traversing the Data Structure

Used for scanning through the JSON elements

JsonRef start ()
 Begin traversal: check for ref validity and reset the position.
 
JsonRef next ()
 Traverse: check for ref validity and increment the position.
 
json_primitive_type GetFirst ()
 Get the first element of the JSON data set.
 
json_primitive_type GetNext ()
 Get the element at the next position of the JSON data set.
 
json_primitive_type GetCurrent ()
 Get the element at the current position of the JSON data set.
 
json_primitive_type GetRawCurrent ()
 Get the element at the current position of the JSON data set, including non-public types.
 
json_primitive_type GetNextName ()
 Iterates the current element of the JSON data set until it finds one of type NAME.
 
json_primitive_type GetNextObject ()
 Get the next element of type name that exists in the current OBJECT after the current position.
 
json_primitive_type GetNextArray ()
 Iterates the current element of the JSON data set until it finds one of type BEGIN_ARRAY.
 
json_primitive_type GetNextNameInCurrentObject ()
 Get the next element of type NAME that exists in the current OBJECT after the current position.
 
json_primitive_type GetNextNameInCurrentArray ()
 Get the next element of type NAME that exists in the current ARRAY after the current position.
 
json_primitive_type GetNextNumberInCurrentArray ()
 Get the next element of type NUMBER that exists in the current ARRAY after the current position.
 
json_primitive_type GetNextStringInCurrentArray ()
 Get the next element of type STRING that exists in the current ARRAY after the current position.
 
json_primitive_type GetNextBoolInCurrentArray ()
 Get the next element of type TRUE_EL that exists in the current ARRAY after the current position.
 
json_primitive_type GetNextObjectInCurrentArray ()
 Get the next element of type BEGIN_OBJECT that exists in the current ARRAY after the current position.
 
json_primitive_type SkipCurrentValue ()
 Skips over the current value, and get the next element. If called inside an ARRAY or OBJECT, it will walk to the end of the ARRAY or OJBECT and return the next element it finds. If it reaches the end of the ARRAY or OBJECT before it finds a value, it will return NOTFOUND.
 
void ResetPosition ()
 Resets the parser position to the beginning of the JSON data set.
 
JsonRef GetParsePosition ()
 Gets the current parse position object for the JSON data set.
 
JsonRef SetParsePosition (JsonRef pos)
 Sets the current parse position object for the JSON data set.
 
Advanced Finding and Returning

Advanced functions for scanning and returning specific objects. All of these can return NOTFOUND.

Example
This function works with dotted string notation to find sub elements:
{
"SUCCESS": true,
"ACTION": null,
"JDATA": {
"foo": 7,
"bar": {
"b1": "Sb1",
"b2": {
"s1": "Sub1",
"s2": "Sub2",
"s3": "Sub3",
"s4": {
"Sub4a": "Test4a",
"Sub4b": "Test4b"
},
"s5": "Sub5",
"s6": "Sub6"
},
"b3": true,
"b4": null
},
"bogus": "Bstring",
"nubog": 1234.57,
"av": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
],
"aftaav": true
}
}
You could return the "Sub4b" element's "Test4b" string with:
myParsedJsonDataSet.FindFullName("JDATA.bar.b2.s4.Sub4b");
json_primitive_type FindFullName (const char *name)
 Find the element in the data set with the given name and move the parser to the next element. This searches a full name path, such as ob1.ob2.ob3.ob4.
 
json_primitive_type FindFullAtName (const char *name)
 Find the element in the data set with the given name and move the parser to that element. This searches a full name path, such as ob1.ob2.ob3.ob4.
 
json_primitive_type FindElementAfterName (const char *name)
 Finds name in current object points at element after name. This only supports simple, single element names. This searches from the current position to the end.
 
json_primitive_type FindGlobalElementAfterName (const char *name)
 Finds name in current object points at element after name. This only supports simple, single element names. It starts the search from the parser's current position, and if it doesn't find it, it will start the search over from the beginning.
 
json_primitive_type FindElementAfterNameInCurrentObject (const char *name)
 Looks for elements with the current name in the current OBJECT only. Does not search sub objects.
 
json_primitive_type FindElementAfterNameInCurrentArray (const char *name)
 Looks for elements with the current name in the current ARRAY only. Does not search sub arrays.
 
bool CurrentBool ()
 Returns true if the current element a TRUE_EL primitive type.
 
bool PermissiveCurrentBool ()
 Returns true if the current element a TRUE_EL primitive type, is "True", "true", or is a non-zero number.
 
double CurrentNumber ()
 Get the number value of the current element.
 
const char * CurrentString ()
 Get the string value of the current element.
 
const char * CurrentName ()
 Get the name of the current element.
 
bool FindFullNameBoolean (const char *name)
 Find the boolean value of a given element.
 
bool FindGlobalBoolean (const char *name)
 Find the boolean value of a given element. Starts at the current position and then starts again at the beginning of the data set if the element isn't found. This supports only simple, single element names.
 
bool FindBoolean (const char *name)
 Find the boolean value of the element after the element with the given name.
 
bool FindBooleanInCurentObject (const char *name)
 Find the boolean value of the element within the current object. Does not search sub-objects.
 
bool FindFullNamePermissiveBoolean (const char *name)
 Find the permissive boolean value of a given element.
 
bool FindGlobalPermissiveBoolean (const char *name)
 Find the permissive boolean value of a given element. Starts at the current position and then starts again at the beginning of the data set if the element isn't found. This supports only simple, single element names.
 
bool FindPermissiveBoolean (const char *name)
 Find the permissive boolean value of the element after the element with the provided name.
 
bool FindPermissiveBooleanInCurentObject (const char *name)
 Find the permissive boolean value of the element with the given name in the current object. Does not search sub-objects.
 
const char * FindFullNameString (const char *name)
 Find the string value of the element with the given name in the current object.
 
const char * FindGlobalString (const char *name)
 Find the string value of a given element. Starts at the current position and then starts again at the beginning of the data set if the element isn't found. This supports only simple, single element names.
 
const char * FindString (const char *name)
 Find the string value of the element after the element with the given name.
 
const char * FindStringInCurentObject (const char *name)
 Find the string value of the element with the given name in the current object. Does not search sub-objects.
 
double FindFullNameNumber (const char *name)
 Find the number value of the element with the given name in the current object.
 
double FindGlobalNumber (const char *name)
 Find the number value of a given element. Starts at the current position and then starts again at the beginning of the data set if the element isn't found. This supports only simple, single element names.
 
double FindNumber (const char *name)
 Find the number value of the element after the element with the given name.
 
double FindNumberInCurentObject (const char *name)
 Find the number value of the element with the given name in the current object. Does not search sub-objects.
 
bool FindGlobalObject (const char *name)
 Find the OBJECT with the given name. Starts at the current position and then starts again at the beginning of the data set if the element isn't found. This supports only simple, single element names.
 
bool FindObject (const char *name)
 Find the OBJECT of the element after the element with the given name.
 
bool FindObjectInCurentObject (const char *name)
 Find the OBJECT of the element with the given name in the current OBJECT. Does not search sub-objects.
 
Utility

Ingesting raw JSON data from some source, or resetting

void DumpState ()
 Outputs what's in the parse tree to stdout.
 
int PrintObject (bool pretty=false)
 Prints the JSON data set to stdout.
 
int PrintObjectToBuffer (char *buffer, int maxlen, bool pretty=false)
 Prints the JSON data set to a provided buffer.
 
int PrintObjectToFd (int fd, bool pretty=false)
 Prints the JSON data set to a specified file descriptor.
 
int PrintObjectToString (NBString &s, bool pretty=false)
 Prints the JSON data set to a NBString object.
 
int PrintChildren (bool pretty=false)
 Output child objects of this JsonRef as JSON text to stdout.
 
int PrintChildrenToFd (int fd, bool pretty=false)
 Output child objects of this JsonRef as JSON text to a file descriptor.
 
int PrintChildrenToBuffer (char *buffer, int maxlen, bool pretty=false)
 Output child objects of this JsonRef as JSON text to a buffer pointer.
 
int GetPrintSize (bool pretty=false)
 Calculates how many characters the JSON data set would take to print.
 
Building

Programmatically creating or modifying a JSON dataset

ParsedJsonDataSetStartBuilding ()
 Use to start building the JSON data set.
 
ParsedJsonDataSetAddObjectStart (const char *name)
 Use to start an object in the JSON data set.
 
ParsedJsonDataSetAddMyMac (const char *name)
 Add the device MAC address to the JSON data set.
 
ParsedJsonDataSetAdd (const char *name, int i)
 Add a name/value pair to the JSON data set where the value is an int.
 
ParsedJsonDataSetAdd (const char *name, short i)
 Add a name/value pair to the JSON data set where the value is a short.
 
ParsedJsonDataSetAdd (const char *name, long i)
 Add a name/value pair to the JSON data set where the value is a long.
 
ParsedJsonDataSetAdd (const char *name, unsigned int i)
 Add a name/value pair to the JSON data set where the value is an unsigned int.
 
ParsedJsonDataSetAdd (const char *name, unsigned short i)
 Add a name/value pair to the JSON data set where the value is a unsigned short.
 
ParsedJsonDataSetAdd (const char *name, unsigned long i)
 Add a name/value pair to the JSON data set where the value is a unsigned long.
 
ParsedJsonDataSetAdd (const char *name, double d)
 Add a name/value pair to the JSON data set where the value is a double.
 
ParsedJsonDataSetAdd (const char *name, const char *str)
 Add a name/value pair to the JSON data set where the value is a string.
 
ParsedJsonDataSetAdd (const char *name, bool b)
 Add a name/value pair to the JSON data set where the value is a bool.
 
ParsedJsonDataSetAdd (const char *name, IPADDR4 i4)
 Add a name/value pair to the JSON data set where the value is an IPv4 address.
 
ParsedJsonDataSetAdd (const char *name, const IPADDR &i)
 Add a name/value pair to the JSON data set where the value is an IP address.
 
ParsedJsonDataSetAdd (const char *name, const MACADR &ma)
 Add a name/value pair to the JSON data set where the value is a MAC address.
 
ParsedJsonDataSetAddNull (const char *name)
 Add a name/value pair to the JSON data set where the value is null.
 
ParsedJsonDataSetAddArrayStart (const char *name)
 Add an ARRAY start to the JSON data set.
 
ParsedJsonDataSetEndArray ()
 Add an ARRAY end to the JSON data set.
 
ParsedJsonDataSetAddArrayElement (int i)
 Add an integer value to the current array.
 
ParsedJsonDataSetAddArrayElement (short i)
 Add a short value to the current array.
 
ParsedJsonDataSetAddArrayElement (long i)
 Add a long value to the current array.
 
ParsedJsonDataSetAddArrayElement (unsigned int i)
 Add an unsigned int value to the current array.
 
ParsedJsonDataSetAddArrayElement (unsigned short i)
 Add an unsigned short value to the current array.
 
ParsedJsonDataSetAddArrayElement (unsigned long i)
 Add an unsigned long value to the current array.
 
ParsedJsonDataSetAddArrayElement (double d)
 Add a double to the current array.
 
ParsedJsonDataSetAddArrayElement (const char *str)
 Add a string to the current array.
 
ParsedJsonDataSetAddArrayElement (bool b)
 Add a bool to the current array.
 
ParsedJsonDataSetAddArrayElement (const IPADDR &i)
 Add an IP address to the current array.
 
ParsedJsonDataSetAddArrayElementArray ()
 Add the start of an array element to the current array.
 
ParsedJsonDataSetAddArrayObjectStart ()
 Add the start of an object element to the current array.
 
ParsedJsonDataSetAddNullArrayElement ()
 Add a null element to the current array.
 
ParsedJsonDataSetEndObject ()
 Add an end to the current object.
 
ParsedJsonDataSetDoneBuilding ()
 Add an end JSON data set and finish building.
 

Friends

class JsonRef
 

Detailed Description

A class to create, read, and modify a JSON object.

Many of the methods on ParsedJsonDataSet return a JsonRef which is a pointer to a variable or sub object inside the ParsedJsonDataSet. So, once data is parsed and traversal or querying has begun most of the work will be inside the JsonRef class.

Member Function Documentation

◆ Add() [1/12]

ParsedJsonDataSet * ParsedJsonDataSet::Add ( const char * name,
bool b )

Add a name/value pair to the JSON data set where the value is a bool.

Parameters
nameThe name of the pair.
bThe value for the pair.

◆ Add() [2/12]

ParsedJsonDataSet * ParsedJsonDataSet::Add ( const char * name,
const char * str )

Add a name/value pair to the JSON data set where the value is a string.

Parameters
nameThe name of the pair.
strA pointer to the value for the pair.

◆ Add() [3/12]

ParsedJsonDataSet * ParsedJsonDataSet::Add ( const char * name,
const IPADDR & i )

Add a name/value pair to the JSON data set where the value is an IP address.

Parameters
nameThe name of the pair.
iThe IP address to add.

◆ Add() [4/12]

ParsedJsonDataSet * ParsedJsonDataSet::Add ( const char * name,
const MACADR & ma )

Add a name/value pair to the JSON data set where the value is a MAC address.

Parameters
nameThe name of the pair.
maThe MAC address to add.

◆ Add() [5/12]

ParsedJsonDataSet * ParsedJsonDataSet::Add ( const char * name,
double d )

Add a name/value pair to the JSON data set where the value is a double.

Parameters
nameThe name of the pair.
dThe value for the pair.

◆ Add() [6/12]

ParsedJsonDataSet * ParsedJsonDataSet::Add ( const char * name,
int i )

Add a name/value pair to the JSON data set where the value is an int.

Parameters
nameThe name of the pair.
iThe value for the pair.

◆ Add() [7/12]

ParsedJsonDataSet * ParsedJsonDataSet::Add ( const char * name,
IPADDR4 i4 )

Add a name/value pair to the JSON data set where the value is an IPv4 address.

Parameters
nameThe name of the pair.
i4The IPv4 address to add.

◆ Add() [8/12]

ParsedJsonDataSet * ParsedJsonDataSet::Add ( const char * name,
long i )

Add a name/value pair to the JSON data set where the value is a long.

Parameters
nameThe name of the pair.
iThe value for the pair.

◆ Add() [9/12]

ParsedJsonDataSet * ParsedJsonDataSet::Add ( const char * name,
short i )

Add a name/value pair to the JSON data set where the value is a short.

Parameters
nameThe name of the pair.
iThe value for the pair.

◆ Add() [10/12]

ParsedJsonDataSet * ParsedJsonDataSet::Add ( const char * name,
unsigned int i )

Add a name/value pair to the JSON data set where the value is an unsigned int.

Parameters
nameThe name of the pair.
iThe value for the pair.

◆ Add() [11/12]

ParsedJsonDataSet * ParsedJsonDataSet::Add ( const char * name,
unsigned long i )

Add a name/value pair to the JSON data set where the value is a unsigned long.

Parameters
nameThe name of the pair.
iThe value for the pair.

◆ Add() [12/12]

ParsedJsonDataSet * ParsedJsonDataSet::Add ( const char * name,
unsigned short i )

Add a name/value pair to the JSON data set where the value is a unsigned short.

Parameters
nameThe name of the pair.
iThe value for the pair.

◆ AddArrayElement() [1/10]

ParsedJsonDataSet * ParsedJsonDataSet::AddArrayElement ( bool b)

Add a bool to the current array.

Parameters
bThe bool value to add.

◆ AddArrayElement() [2/10]

ParsedJsonDataSet * ParsedJsonDataSet::AddArrayElement ( const char * str)

Add a string to the current array.

Parameters
strA char* pointing to the string value to add.

◆ AddArrayElement() [3/10]

ParsedJsonDataSet * ParsedJsonDataSet::AddArrayElement ( const IPADDR & i)

Add an IP address to the current array.

Parameters
iThe IP address to add.

◆ AddArrayElement() [4/10]

ParsedJsonDataSet * ParsedJsonDataSet::AddArrayElement ( double d)

Add a double to the current array.

Parameters
dThe double value to add.

◆ AddArrayElement() [5/10]

ParsedJsonDataSet * ParsedJsonDataSet::AddArrayElement ( int i)

Add an integer value to the current array.

Parameters
iThe integer value to add.

◆ AddArrayElement() [6/10]

ParsedJsonDataSet * ParsedJsonDataSet::AddArrayElement ( long i)

Add a long value to the current array.

Parameters
iThe long value to add.

◆ AddArrayElement() [7/10]

ParsedJsonDataSet * ParsedJsonDataSet::AddArrayElement ( short i)

Add a short value to the current array.

Parameters
iThe short value to add.

◆ AddArrayElement() [8/10]

ParsedJsonDataSet * ParsedJsonDataSet::AddArrayElement ( unsigned int i)

Add an unsigned int value to the current array.

Parameters
iThe unsigned int value to add.

◆ AddArrayElement() [9/10]

ParsedJsonDataSet * ParsedJsonDataSet::AddArrayElement ( unsigned long i)

Add an unsigned long value to the current array.

Parameters
iThe unsigned long value to add.

◆ AddArrayElement() [10/10]

ParsedJsonDataSet * ParsedJsonDataSet::AddArrayElement ( unsigned short i)

Add an unsigned short value to the current array.

Parameters
iThe unsigned short value to add.

◆ AddArrayStart()

ParsedJsonDataSet * ParsedJsonDataSet::AddArrayStart ( const char * name)

Add an ARRAY start to the JSON data set.

Parameters
nameThe name of the array to start.

◆ AddMyMac()

ParsedJsonDataSet * ParsedJsonDataSet::AddMyMac ( const char * name)

Add the device MAC address to the JSON data set.

Parameters
nameThe name of the field containing the MAC address.

◆ AddNull()

ParsedJsonDataSet * ParsedJsonDataSet::AddNull ( const char * name)

Add a name/value pair to the JSON data set where the value is null.

Parameters
nameThe name of the pair.

◆ AddObjectStart()

ParsedJsonDataSet * ParsedJsonDataSet::AddObjectStart ( const char * name)

Use to start an object in the JSON data set.

Parameters
nameThe name of the object to start.

◆ CopyObject()

bool ParsedJsonDataSet::CopyObject ( ParsedJsonDataSet & src_set)

Copies the provided JSON data set into the current one.

Return values
trueThe copy succeeded.
falseThe copy failed.

◆ CurrentBool()

bool ParsedJsonDataSet::CurrentBool ( )
inline

Returns true if the current element a TRUE_EL primitive type.

Return values
trueIf the current element is a TRUE_EL primitive type.
falseIf the current element is not a TRUE_EL primitive type.

◆ CurrentName()

const char * ParsedJsonDataSet::CurrentName ( )
inline

Get the name of the current element.

Returns
A pointer to the name of the current element, if it has one. If it does not, it returns a 0.

◆ CurrentNumber()

double ParsedJsonDataSet::CurrentNumber ( )
inline

Get the number value of the current element.

Returns
The number value if the current element's primitive type is NUMBER. Otherwise it returns a quite NAN.

◆ CurrentString()

const char * ParsedJsonDataSet::CurrentString ( )
inline

Get the string value of the current element.

Returns
The a pointer to the string value of the current element if it is of primitive type STRING or ALLOC_STRING. Otherwise it returns a 0.

◆ FindBoolean()

bool ParsedJsonDataSet::FindBoolean ( const char * name)
inline

Find the boolean value of the element after the element with the given name.

Parameters
nameThe name of the element to find.
Return values
trueIf the element is of the TRUE_EL primitive type.
falseIf the element is not of the TRUE_EL primitive type.

◆ FindBooleanInCurentObject()

bool ParsedJsonDataSet::FindBooleanInCurentObject ( const char * name)
inline

Find the boolean value of the element within the current object. Does not search sub-objects.

Parameters
nameThe name of the element to find.
Return values
trueIf the element is of the TRUE_EL primitive type.
falseIf the element is not of the TRUE_EL primitive type.

◆ FindElementAfterName()

json_primitive_type ParsedJsonDataSet::FindElementAfterName ( const char * name)
inline

Finds name in current object points at element after name. This only supports simple, single element names. This searches from the current position to the end.

Parameters
nameThe name to look for.
Returns
The type that the parser is now currently set to.
Return values
NOTFOUNDIf the an element with the name wasn't found.

◆ FindElementAfterNameInCurrentArray()

json_primitive_type ParsedJsonDataSet::FindElementAfterNameInCurrentArray ( const char * name)
inline

Looks for elements with the current name in the current ARRAY only. Does not search sub arrays.

Parameters
nameThe name to look for.
Returns
The type that the parser is now currently set to.
Return values
NOTFOUNDIf the an element with the name wasn't found.

◆ FindElementAfterNameInCurrentObject()

json_primitive_type ParsedJsonDataSet::FindElementAfterNameInCurrentObject ( const char * name)
inline

Looks for elements with the current name in the current OBJECT only. Does not search sub objects.

Parameters
nameThe name to look for.
Returns
The type that the parser is now currently set to.
Return values
NOTFOUNDIf the an element with the name wasn't found.

◆ FindFullAtName()

json_primitive_type ParsedJsonDataSet::FindFullAtName ( const char * name)
inline

Find the element in the data set with the given name and move the parser to that element. This searches a full name path, such as ob1.ob2.ob3.ob4.

Parameters
nameThe full name to look for.
Returns
The type that the parser is now currently set to.
Return values
NOTFOUNDIf the an element with the name wasn't found.

◆ FindFullName()

json_primitive_type ParsedJsonDataSet::FindFullName ( const char * name)
inline

Find the element in the data set with the given name and move the parser to the next element. This searches a full name path, such as ob1.ob2.ob3.ob4.

Parameters
nameThe full name to look for.
Returns
The type that the parser is now currently set to.
Return values
NOTFOUNDIf the an element with the name wasn't found, or there is no element after the named element.

◆ FindFullNameBoolean()

bool ParsedJsonDataSet::FindFullNameBoolean ( const char * name)
inline

Find the boolean value of a given element.

Parameters
nameThe full name of the element to find.
Return values
trueIf the element is of the TRUE_EL primitive type.
falseIf the element is not of the TRUE_EL primitive type.

◆ FindFullNameNumber()

double ParsedJsonDataSet::FindFullNameNumber ( const char * name)
inline

Find the number value of the element with the given name in the current object.

Parameters
nameThe full name of the element to find.
Returns
The number value of the element if found, otherwise a quiet nan.

◆ FindFullNamePermissiveBoolean()

bool ParsedJsonDataSet::FindFullNamePermissiveBoolean ( const char * name)
inline

Find the permissive boolean value of a given element.

Parameters
nameThe full name of the element to find.
Return values
trueIf the current element a TRUE_EL primitive type, is "True", "true", or is a non-zero number.
falseIf the current element is not a TRUE_EL primitive type, "True", "true", or is 0.

◆ FindFullNameString()

const char * ParsedJsonDataSet::FindFullNameString ( const char * name)
inline

Find the string value of the element with the given name in the current object.

Parameters
nameThe full name of the element to find.
Returns
A pointer to the buffer if the string is found, or null otherwise.

◆ FindGlobalBoolean()

bool ParsedJsonDataSet::FindGlobalBoolean ( const char * name)
inline

Find the boolean value of a given element. Starts at the current position and then starts again at the beginning of the data set if the element isn't found. This supports only simple, single element names.

Parameters
nameThe name of the element to find.
Return values
trueIf the element is of the TRUE_EL primitive type.
falseIf the element is not of the TRUE_EL primitive type.

◆ FindGlobalElementAfterName()

json_primitive_type ParsedJsonDataSet::FindGlobalElementAfterName ( const char * name)
inline

Finds name in current object points at element after name. This only supports simple, single element names. It starts the search from the parser's current position, and if it doesn't find it, it will start the search over from the beginning.

Parameters
nameThe name to look for.
Returns
The type that the parser is now currently set to.
Return values
NOTFOUNDIf the an element with the name wasn't found.

◆ FindGlobalNumber()

double ParsedJsonDataSet::FindGlobalNumber ( const char * name)
inline

Find the number value of a given element. Starts at the current position and then starts again at the beginning of the data set if the element isn't found. This supports only simple, single element names.

Parameters
nameThe name of the element to find.
Returns
The number value of the element if found, otherwise a quiet nan.

◆ FindGlobalObject()

bool ParsedJsonDataSet::FindGlobalObject ( const char * name)
inline

Find the OBJECT with the given name. Starts at the current position and then starts again at the beginning of the data set if the element isn't found. This supports only simple, single element names.

Parameters
nameThe name of the OBJECT to find.
Return values
trueIf the OBJECT was found. The current position will be set to the start of the OBJECT.
falseIf the OBJECT was not found.

◆ FindGlobalPermissiveBoolean()

bool ParsedJsonDataSet::FindGlobalPermissiveBoolean ( const char * name)
inline

Find the permissive boolean value of a given element. Starts at the current position and then starts again at the beginning of the data set if the element isn't found. This supports only simple, single element names.

Parameters
nameThe name of the element to find.
Return values
trueIf the current element a TRUE_EL primitive type, is "True", "true", or is a non-zero number.
falseIf the current element is not a TRUE_EL primitive type, "True", "true", or is 0.

◆ FindGlobalString()

const char * ParsedJsonDataSet::FindGlobalString ( const char * name)
inline

Find the string value of a given element. Starts at the current position and then starts again at the beginning of the data set if the element isn't found. This supports only simple, single element names.

Parameters
nameThe name of the element to find.
Returns
A pointer to the buffer if the string is found, or null otherwise.

◆ FindNumber()

double ParsedJsonDataSet::FindNumber ( const char * name)
inline

Find the number value of the element after the element with the given name.

Parameters
nameThe name of the element to find.
Returns
The number value of the element if found, otherwise a quiet nan.

◆ FindNumberInCurentObject()

double ParsedJsonDataSet::FindNumberInCurentObject ( const char * name)
inline

Find the number value of the element with the given name in the current object. Does not search sub-objects.

Parameters
nameThe name of the element to find.
Returns
The number value of the element if found, otherwise a quiet nan.

◆ FindObject()

bool ParsedJsonDataSet::FindObject ( const char * name)
inline

Find the OBJECT of the element after the element with the given name.

Parameters
nameThe name of the OBJECT to find.
Return values
trueIf the OBJECT was found. The current position will be set to the start of the OBJECT.
falseIf the OBJECT was not found.

◆ FindObjectInCurentObject()

bool ParsedJsonDataSet::FindObjectInCurentObject ( const char * name)
inline

Find the OBJECT of the element with the given name in the current OBJECT. Does not search sub-objects.

Parameters
nameThe name of the OBJECT to find.
Return values
trueIf the OBJECT was found. The current position will be set to the start of the OBJECT.
falseIf the OBJECT was not found.

◆ FindPermissiveBoolean()

bool ParsedJsonDataSet::FindPermissiveBoolean ( const char * name)
inline

Find the permissive boolean value of the element after the element with the provided name.

Parameters
nameThe name of element to search on.
Return values
trueIf the current element a TRUE_EL primitive type, is "True", "true", or is a non-zero number.
falseIf the current element is not a TRUE_EL primitive type, "True", "true", or is 0.

◆ FindPermissiveBooleanInCurentObject()

bool ParsedJsonDataSet::FindPermissiveBooleanInCurentObject ( const char * name)
inline

Find the permissive boolean value of the element with the given name in the current object. Does not search sub-objects.

Parameters
nameThe name of the element to find.
Return values
trueIf the current element a TRUE_EL primitive type, is "True", "true", or is a non-zero number.
falseIf the current element is not a TRUE_EL primitive type, "True", "true", or is 0.

◆ FindString()

const char * ParsedJsonDataSet::FindString ( const char * name)
inline

Find the string value of the element after the element with the given name.

Parameters
nameThe name of the element to find.
Returns
A pointer to the buffer if the string is found, or null otherwise.

◆ FindStringInCurentObject()

const char * ParsedJsonDataSet::FindStringInCurentObject ( const char * name)
inline

Find the string value of the element with the given name in the current object. Does not search sub-objects.

Parameters
nameThe name of the element to find.
Returns
A pointer to the buffer if the string is found, or null otherwise.

◆ GetCurrent()

json_primitive_type ParsedJsonDataSet::GetCurrent ( )
inline

Get the element at the current position of the JSON data set.

Returns
The current element of the JSON data set.
Return values
UNDEFINEDIf there is an error in the parsing or if the parsing is not complete.
EOF_ELIf it's the last element in the data set.
See also
GetFirst()
GetNext()
GetRawCurrent()
SkipCurrentValue()
ResetPosition()

◆ GetFirst()

json_primitive_type ParsedJsonDataSet::GetFirst ( )
inline

Get the first element of the JSON data set.

Returns
The first element of the JSON data set.
Return values
UNDEFINEDIf there is an error in the parsing or if the parsing is not complete.
EOF_ELIf it's the last element in the data set.
See also
GetNext()
GetCurrent()
GetRawCurrent()
ResetPosition()
SkipCurrentValue()

◆ GetNext()

json_primitive_type ParsedJsonDataSet::GetNext ( )
inline

Get the element at the next position of the JSON data set.

Returns
The next element of the JSON data set.
Return values
UNDEFINEDIf there is an error in the parsing or if the parsing is not complete.
EOF_ELIf it's the last element in the data set.
See also
GetFirst()
GetCurrent()
GetRawCurrent()
ResetPosition()
SkipCurrentValue()

◆ GetNextArray()

json_primitive_type ParsedJsonDataSet::GetNextArray ( )

Iterates the current element of the JSON data set until it finds one of type BEGIN_ARRAY.

Returns
The next element with type BEGIN_ARRAY after the current position.
Return values
NOTFOUNDIf there is no BEGIN_ARRAY element after the current position.
See also
GetNextNameInCurrentObject()
GetNextNameInCurrentArray()

◆ GetNextBoolInCurrentArray()

json_primitive_type ParsedJsonDataSet::GetNextBoolInCurrentArray ( )

Get the next element of type TRUE_EL that exists in the current ARRAY after the current position.

Returns
The next element with type TRUE_EL in the current ARRAY after the current position.
Return values
NOTFOUNDIf there is no NAME element after the current position.
See also
CurrentBool()
PermissiveCurrentBool()

◆ GetNextName()

json_primitive_type ParsedJsonDataSet::GetNextName ( )
inline

Iterates the current element of the JSON data set until it finds one of type NAME.

Returns
The next element with type NAME after the current position.
Return values
NOTFOUNDIf there is no NAME element after the current position.
See also
GetNextNameInCurrentObject()
GetNextNameInCurrentArray()

◆ GetNextNameInCurrentArray()

json_primitive_type ParsedJsonDataSet::GetNextNameInCurrentArray ( )
inline

Get the next element of type NAME that exists in the current ARRAY after the current position.

Returns
The next element with type NAME in the current ARRAY after the current position.
Return values
NOTFOUNDIf there is no NAME element after the current position.
See also
GetNextName()
GetNextNameInCurrentObject()

◆ GetNextNameInCurrentObject()

json_primitive_type ParsedJsonDataSet::GetNextNameInCurrentObject ( )
inline

Get the next element of type NAME that exists in the current OBJECT after the current position.

Returns
The next element with type NAME in the current OBJECT after the current position.
Return values
NOTFOUNDIf there is no NAME element after the current position.
See also
GetNextName()
GetNextNameInCurrentArray()

◆ GetNextNumberInCurrentArray()

json_primitive_type ParsedJsonDataSet::GetNextNumberInCurrentArray ( )

Get the next element of type NUMBER that exists in the current ARRAY after the current position.

Returns
The next element with type NUMBER in the current ARRAY after the current position.
Return values
NOTFOUNDIf there is no NAME element after the current position.
See also
CurrentNumber()

◆ GetNextObject()

json_primitive_type ParsedJsonDataSet::GetNextObject ( )

Get the next element of type name that exists in the current OBJECT after the current position.

Returns
The next element with type BEGIN_OBJECT after the current position.
Return values
NOTFOUNDIf there is no BEGIN_OBJECT element after the current position.
See also
GetNextNameInCurrentObject()
GetNextNameInCurrentArray()

◆ GetNextObjectInCurrentArray()

json_primitive_type ParsedJsonDataSet::GetNextObjectInCurrentArray ( )

Get the next element of type BEGIN_OBJECT that exists in the current ARRAY after the current position.

Returns
The next element with type BEGIN_OBJECT in the current ARRAY after the current position.
Return values
NOTFOUNDIf there is no BEGIN_OBJECT element after the current position.
See also
GetNextName()
GetNextNameInCurrentObject()

◆ GetNextStringInCurrentArray()

json_primitive_type ParsedJsonDataSet::GetNextStringInCurrentArray ( )

Get the next element of type STRING that exists in the current ARRAY after the current position.

Returns
The next element with type STRING in the current ARRAY after the current position.
Return values
NOTFOUNDIf there is no NAME element after the current position.
See also
CurrentString()

◆ GetParsePosition()

JsonRef ParsedJsonDataSet::GetParsePosition ( )

Gets the current parse position object for the JSON data set.

Returns
The current parse position object.

◆ GetPrintSize()

int ParsedJsonDataSet::GetPrintSize ( bool pretty = false)
inline

Calculates how many characters the JSON data set would take to print.

Parameters
prettyWhether indentation and new lines should be provided between elements.
Returns
The number of characters needed to print the JSON data set.

◆ GetRawCurrent()

json_primitive_type ParsedJsonDataSet::GetRawCurrent ( )
inline

Get the element at the current position of the JSON data set, including non-public types.

Returns
The current element of the JSON data set.
Return values
UNDEFINEDIf there is an error in the parsing or if the parsing is not complete.
EOF_ELIf it's the last element in the data set.
See also
GetFirst()
GetNext()
GetCurrent()
ResetPosition()
SkipCurrentValue()

◆ name()

JsonRef ParsedJsonDataSet::name ( const char * name)
inline

Get a JsonRef representing any entity from a parent object by key name.

Useful if more than one JSON object/element has the same name.

Example
JsonRef userThree = myJsonRef.name("users")[3];
Represents a positional reference (pointer) of a location inside a ParsedJsonDataSet object
Definition json_lexer.h:112
JsonRef name(const char *name)
Get a JsonRef representing any entity from a parent object by key name.
Parameters
*namePointer to name of the entity to find
Returns
The reference to the entity of type JsonRef
See also
ParsedJsonDataSet::operator()(), ParsedJsonDataSet::object()

◆ object()

JsonRef ParsedJsonDataSet::object ( const char * name)
inline

Get a JsonRef representing an object from a parent object by key name.

Example
JsonRef john = myJsonRef.object("users").object("john");
JsonRef object(const char *name)
Get a JsonRef representing an object from a parent object by key name.
Definition json_lexer.h:183
Parameters
*namePointer to name of the object to find
Returns
The reference to the object of type JsonRef

◆ operator()()

JsonRef ParsedJsonDataSet::operator() ( const char * name)
inline

Get a JsonRef representing any entity from a parent object by key name.

Shortcut for JsonRef::name()

Example
JsonRef allUsers = myJsonRef("users");
Parameters
*namePointer to name of the entity to find
Returns
The reference to the entity of type JsonRef
See also
ParsedJsonDataSet::name(), ParsedJsonDataSet::object()

◆ operator[]()

JsonRef ParsedJsonDataSet::operator[] ( int i)
inline

Get a JsonRef from an array by numerical index.

Example
JsonRef userThree = myJsonRef("users")[3];
Returns
A JsonRef if array element is found

◆ PermissiveCurrentBool()

bool ParsedJsonDataSet::PermissiveCurrentBool ( )
inline

Returns true if the current element a TRUE_EL primitive type, is "True", "true", or is a non-zero number.

Return values
trueIf the current element a TRUE_EL primitive type, is "True", "true", or is a non-zero number.
falseIf the current element does not meet the true condition..

◆ PrintObject()

int ParsedJsonDataSet::PrintObject ( bool pretty = false)
inline

Prints the JSON data set to stdout.

Parameters
prettyWhether to show indentation and new lines between JSON elements.

◆ PrintObjectToBuffer()

int ParsedJsonDataSet::PrintObjectToBuffer ( char * buffer,
int maxlen,
bool pretty = false )
inline

Prints the JSON data set to a provided buffer.

Parameters
bufferThe buffer to print to.
maxlenThe max length of the buffer.
prettyWhether indentation and new lines should be provided between elements.
Returns
The number of characters printed.

◆ PrintObjectToFd()

int ParsedJsonDataSet::PrintObjectToFd ( int fd,
bool pretty = false )
inline

Prints the JSON data set to a specified file descriptor.

Parameters
fdThe file descriptor to print to.
prettyWhether indentation and new lines should be provided between elements.

◆ PrintObjectToString()

int ParsedJsonDataSet::PrintObjectToString ( NBString & s,
bool pretty = false )
inline

Prints the JSON data set to a NBString object.

Parameters
sThe NBString to print to.
prettyWhether indentation and new lines should be provided between elements.

◆ ReadFrom()

virtual int ParsedJsonDataSet::ReadFrom ( int fd)
virtual

Reads in data from the specified file descriptor and parses it into the JSON data set.

Parameters
fdThe file descriptor to read data from.
Returns
The number of bytes read

◆ ResetPosition()

void ParsedJsonDataSet::ResetPosition ( )
inline

Resets the parser position to the beginning of the JSON data set.

See also
GetFirst()
GetNext()
GetCurrent()
SkipCurrentValue()

◆ SetParsePosition()

JsonRef ParsedJsonDataSet::SetParsePosition ( JsonRef pos)

Sets the current parse position object for the JSON data set.

Parameters
posThe JsonRef that you want to set the current position to.
Returns
The current parse ref position for the JSON data set.

◆ SkipCurrentValue()

json_primitive_type ParsedJsonDataSet::SkipCurrentValue ( )
inline

Skips over the current value, and get the next element. If called inside an ARRAY or OBJECT, it will walk to the end of the ARRAY or OJBECT and return the next element it finds. If it reaches the end of the ARRAY or OBJECT before it finds a value, it will return NOTFOUND.

Returns
The next element.
Return values
NOTFOUNDIf there are no other elements after the current one.
See also
GetFirst()
GetCurrent()
GetNext()
ResetPosition()
SkipCurrentValue()

◆ WriteData()

virtual int ParsedJsonDataSet::WriteData ( const unsigned char * pCopyFrom,
int numBytes )
virtual

Writes the passed in data to the JSON data set.

Parameters
pCopyFromWhat data to write.
numBytesHow many bytes to copy.
Returns
The number of bytes written

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