NetBurner 3.5.0
PDF Version
 
JSON Lexer

NetBurner's JSON library. See more details and examples below. More...

Classes

struct  JsonAllocString
 A list of large strings that are created with malloc. More...
 
class  JsonRef
 Represents a positional reference (pointer) of a location inside a ParsedJsonDataSet object
More...
 
class  ParsedJsonDataSet
 A class to create, read, and modify a JSON object. More...
 
class  JsonLexerFDAdapter
 Get the type name of the JSON primitive type passed in. More...
 

Typedefs

typedef void CharOutputFn(const char *chars, int len, void *blob)
 Helper function typedef for print functions.
 

Enumerations

enum  json_primitive_type {
  UNDEFINED , BEGIN_ARRAY , BEGIN_OBJECT , END_ARRAY ,
  END_OBJECT , NAME , STRING , VALUE_SEPERATOR ,
  NUMBER , FALSE_EL , TRUE_EL , NULL_EL ,
  STRING_TOO_BIG , ALLOC_STRING , NOTFOUND , EOF_EL
}
 The following types define the basic building blocks that make up a JSON data set. These are the values that will be returned from the functions used to parse the data set. Member functions include operators to return specific data type, as well as type validity checks. More...
 

Detailed Description

NetBurner's JSON library. See more details and examples below.

#include< json_lexer.h >

The library enables rapid, performant parsing, traversal, and querying of JSON data. It also works seamlessly as a buffer_object for the Web Client's DoGet() function.

ParsedJsonDataSet is the root object that holds the document, and JsonRef is the result of each query function, serving as a pointer to a location in the document but also as a chainable query and inspection interface.

See also the JSON Lexer Example Applications.

Example
bool result = DoGet("https://www.example.com/users.json", pjd);
// pjd.PrintObject(true);
// pjd("users").PrintChildren(true);
if (!result ||
!pjd("users")[0].IsObject() ||
!pjd("users")[0]("id").IsNumber() ||
!pjd("users")[0]("name").IsString()
) {
return false;
}
printf("Got user %d name %s",
(int)pjd("users")[0]("id"),
(const char *)pjd("users")[0]("name")
);
A class to create, read, and modify a JSON object.
Definition json_lexer.h:530
bool DoGet(ParsedURI &TheUri, buffer_object &result_buffer, uint16_t TIMEOUT_WAIT=10 *TICKS_PER_SECOND)

Typedef Documentation

◆ CharOutputFn

typedef void CharOutputFn(const char *chars, int len, void *blob)

#include <json_lexer.h>

Helper function typedef for print functions.

Parameters
charsThe characters to print.
lenThe length of the characters to print.
blobA pointer to where they should be printed.

Enumeration Type Documentation

◆ json_primitive_type

#include <json_lexer.h>

The following types define the basic building blocks that make up a JSON data set. These are the values that will be returned from the functions used to parse the data set. Member functions include operators to return specific data type, as well as type validity checks.

Enumerator
UNDEFINED 

Not a defined primitive type. This indicates an error somewhere.

BEGIN_ARRAY 

[ - Signals the start of an array.

BEGIN_OBJECT 

{ - Signals the start of an object.

END_ARRAY 

] - Signals the end of an array.

END_OBJECT 

} - Signals the end of an object.

NAME 

"xxx": - Signals the name of a name/value pair.

STRING 

"xxx" - An element with a string value.

VALUE_SEPERATOR 

, - Signals the separation between to arrays, objects, or values.

NUMBER 

An element with a number value.

FALSE_EL 

An element with the value false.

TRUE_EL 

An element with the value true.

NULL_EL 

An element with the null value.

STRING_TOO_BIG 

Error, we got a sting but it was too big to fit in the storage scheme (1500 bytes).

ALLOC_STRING 

We allocated a large string.

NOTFOUND 

Return value when we don't find what we are looking for.

EOF_EL 

Last token in the data set.