Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
Data Structures
json.h File Reference

Header file for the JSON component. Defines API prototypes. More...

#include "../utilities/utilities.h"
Include dependency graph for json.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  json_number
 The structure of a JSON number value. More...
 
struct  json_value_tag
 The structure of a JSON value. More...
 

Macros

Value Identifiers

Integer identifiers for each of the JSON value types.

#define JSON_ID_OBJECT   11
 Object value. More...
 
#define JSON_ID_ARRAY   13
 Array value. More...
 
#define JSON_ID_STRING   14
 String value. More...
 
#define JSON_ID_NUMBER   15
 Number value. More...
 
#define JSON_ID_TRUE   16
 Literal value is true. More...
 
#define JSON_ID_FALSE   17
 Literal value is false. More...
 
#define JSON_ID_NULL   18
 Literal value is null. More...
 
Number Type Identifiers

APG specifies numbers as one of three types – floating point, unsigned integer and signed integer. These identifiers are used to indicate which.

#define JSON_ID_FLOAT   19
 Number value is a double floating point number. More...
 
#define JSON_ID_SIGNED   20
 Number value is a 64-bit signed integer. More...
 
#define JSON_ID_UNSIGNED   21
 Number value is a 64-bit unsigned integer. More...
 

Functions

Construction and Destruction
void * vpJsonCtor (exception *spEx)
 The JSON constructor. More...
 
void vJsonDtor (void *vpCtx)
 The JSON Parser component destructor. More...
 
abool bJsonValidate (void *vpCtx)
 Validate a JSON context pointer. More...
 
Read and Write

Reads and writes UTF-8 byte streams. JSON files are parsed as they are read. JSON files are converted to UTF-8 as they are written.

void * vpJsonReadFile (void *vpCtx, const char *cpFileName)
 The JSON file reader. More...
 
void * vpJsonReadArray (void *vpCtx, uint8_t *ucpData, aint uiDataLen)
 The JSON array reader. More...
 
uint8_t * ucpJsonWrite (void *vpCtx, json_value *spValue, aint *uipCount)
 Converts a sub-tree of values into UTF-8 byte stream of JSON text. More...
 
Accessing JSON Tree Nodes

Find trees, sub-trees, node siblings and specified key names.

void * vpJsonFindKeyA (void *vpCtx, const char *cpKey, json_value *spValue)
 Find JSON values with a specified ASCII key. More...
 
void * vpJsonFindKeyU (void *vpCtx, const uint32_t *uipKey, aint uiLength, json_value *spValue)
 Find JSON values with the specified 32-bit Unicode key. More...
 
void * vpJsonTree (void *vpCtx, json_value *spValue)
 Initialize the iterator to walk a value tree. More...
 
void * vpJsonChildren (void *vpCtx, json_value *spValue)
 Initialize the iterator over the children of the given value as the parent node. More...
 
Value Iterators

void vJsonIteratorDtor (void *vpIteratorCtx)
 The JSON iterator destructor. More...
 
json_value * spJsonIteratorFirst (void *vpIteratorCtx)
 Find the first value in the list represented by this iterator. More...
 
json_value * spJsonIteratorLast (void *vpIteratorCtx)
 Find the last value in the list represented by this iterator. More...
 
json_value * spJsonIteratorNext (void *vpIteratorCtx)
 Find the next value in the list represented by this iterator. More...
 
json_value * spJsonIteratorPrev (void *vpIteratorCtx)
 Find the prev value in the list represented by this iterator. More...
 
aint uiJsonIteratorCount (void *vpIteratorCtx)
 Find the number of values in the list represented by this iterator. More...
 
JSON Builder

For simple ASCII characters, one can easily just type a JSON file into a word processor. The syntax is that simple. However, for general 32- or even 64-bit alphabet characters this is not possible. This suite of functions – implemented as a sub-object – can build Unicode strings and arbitrary-width numbers into JSON

void * vpJsonBuildCtor (void *vpJsonCtx)
 The builder object constructor. More...
 
void vJsonBuildDtor (void *vpBuildCtx)
 The builder object destructor. More...
 
void vJsonBuildClear (void *vpBuildCtx)
 Clears all memory associated with this builder object. More...
 
aint uiJsonBuildMakeStringA (void *vpBuildCtx, const char *cpString)
 Make a string value from a null-terminated ASCII string. More...
 
aint uiJsonBuildMakeStringU (void *vpBuildCtx, const uint32_t *uipData, aint uiLength)
 Make a string value from UTF-32 code points. More...
 
aint uiJsonBuildMakeNumberF (void *vpBuildCtx, double dNumber)
 Make a JSON floating point number value. More...
 
aint uiJsonBuildMakeNumberS (void *vpBuildCtx, int64_t iNumber)
 Make a JSON signed integer number value. More...
 
aint uiJsonBuildMakeNumberU (void *vpBuildCtx, uint64_t uiNumber)
 Make a JSON unsigned integer number value. More...
 
aint uiJsonBuildMakeTrue (void *vpBuildCtx)
 Make a JSON true value. More...
 
aint uiJsonBuildMakeFalse (void *vpBuildCtx)
 Make a JSON false value. More...
 
aint uiJsonBuildMakeNull (void *vpBuildCtx)
 Make a JSON null value. More...
 
aint uiJsonBuildMakeObject (void *vpBuildCtx)
 Make a JSON object value. More...
 
aint uiJsonBuildMakeArray (void *vpBuildCtx)
 Makea JSON array value. More...
 
aint uiJsonBuildAddToObject (void *vpBuildCtx, aint uiObject, aint uiKey, aint uiAdd)
 Add a child value to a parent object value. More...
 
aint uiJsonBuildAddToArray (void *vpBuildCtx, aint uiArray, aint uiAdd)
 Add a child value to a parent array value. More...
 
void * vpJsonBuild (void *vpBuildCtx, aint uiRoot)
 Build the JSON object. More...
 
Display Helpers
void vJsonDisplayValue (void *vpCtx, json_value *spValue, aint uiDepth)
 Display a value and optionally the values in the branch below, if any. More...
 
void vJsonDisplayInput (void *vpCtx, abool bShowLines)
 Display the input JSON byte stream. More...
 

Detailed Description

Header file for the JSON component. Defines API prototypes.

Definition in file json.h.

Macro Definition Documentation

◆ JSON_ID_ARRAY

#define JSON_ID_ARRAY   13

Array value.

Definition at line 49 of file json.h.

◆ JSON_ID_FALSE

#define JSON_ID_FALSE   17

Literal value is false.

Definition at line 53 of file json.h.

◆ JSON_ID_FLOAT

#define JSON_ID_FLOAT   19

Number value is a double floating point number.

Definition at line 62 of file json.h.

◆ JSON_ID_NULL

#define JSON_ID_NULL   18

Literal value is null.

Definition at line 54 of file json.h.

◆ JSON_ID_NUMBER

#define JSON_ID_NUMBER   15

Number value.

Definition at line 51 of file json.h.

◆ JSON_ID_OBJECT

#define JSON_ID_OBJECT   11

Object value.

Definition at line 48 of file json.h.

◆ JSON_ID_SIGNED

#define JSON_ID_SIGNED   20

Number value is a 64-bit signed integer.

Definition at line 63 of file json.h.

◆ JSON_ID_STRING

#define JSON_ID_STRING   14

String value.

Definition at line 50 of file json.h.

◆ JSON_ID_TRUE

#define JSON_ID_TRUE   16

Literal value is true.

Definition at line 52 of file json.h.

◆ JSON_ID_UNSIGNED

#define JSON_ID_UNSIGNED   21

Number value is a 64-bit unsigned integer.

Definition at line 64 of file json.h.

Function Documentation

◆ bJsonValidate()

abool bJsonValidate ( void *  vpCtx)

Validate a JSON context pointer.

Parameters
vpCtxPointer to a possibly valid JSON context returned from vpJsonCtor().
Returns
True if the pointer is valid, false otherwise.

Definition at line 188 of file json.c.

◆ spJsonIteratorFirst()

json_value* spJsonIteratorFirst ( void *  vpIteratorCtx)

Find the first value in the list represented by this iterator.

Parameters
vpIteratorCtxA valid context pointer returned from any of the iterator-generating functions. If invalid the application will silently exit with a BAD_CONTEXT exit code.
Returns
A pointer to the first value in the list.

Definition at line 613 of file json.c.

◆ spJsonIteratorLast()

json_value* spJsonIteratorLast ( void *  vpIteratorCtx)

Find the last value in the list represented by this iterator.

Parameters
vpIteratorCtxA valid context pointer returned from any of the iterator-generating functions. If invalid the application will silently exit with a BAD_CONTEXT exit code.
Returns
A pointer to the last value in the list.

Definition at line 627 of file json.c.

◆ spJsonIteratorNext()

json_value* spJsonIteratorNext ( void *  vpIteratorCtx)

Find the next value in the list represented by this iterator.

It should be preceded by a call to spJsonIteratorFirst()

Parameters
vpIteratorCtxA valid context pointer returned from any of the iterator-generating functions. If invalid the application will silently exit with a BAD_CONTEXT exit code.
Returns
A pointer to the next value in the list. NULL if there are no more values in the list.

Definition at line 647 of file json.c.

◆ spJsonIteratorPrev()

json_value* spJsonIteratorPrev ( void *  vpIteratorCtx)

Find the prev value in the list represented by this iterator.

It should be preceded by a call to spJsonIteratorNext()

Parameters
vpIteratorCtxA valid context pointer returned from any of the iterator-generating functions. If invalid the application will silently exit with a BAD_CONTEXT exit code.
Returns
A pointer to the previous value in the list. NULL if the current value is the first value in the list.

Definition at line 671 of file json.c.

◆ ucpJsonWrite()

uint8_t* ucpJsonWrite ( void *  vpCtx,
json_value *  spValue,
aint uipCount 
)

Converts a sub-tree of values into UTF-8 byte stream of JSON text.

Parameters
vpCtxPointer to a valid parser context previously returned from vpJsonCtor. If invalid the application will silently exit with a BAD_CONTEXT exit code.
spValueThe root node of the sub-tree to write. spValue can be any value, including the root value, of an existing value tree.
uipCountPointer to an unsigned integer. On completion the number of bytes in the output JSON text is written here.
Returns
Returns a pointer to the JSON text byte stream. The pointer is valid until another call to this function.

Definition at line 329 of file json.c.

◆ uiJsonBuildAddToArray()

aint uiJsonBuildAddToArray ( void *  vpBuildCtx,
aint  uiArray,
aint  uiAdd 
)

Add a child value to a parent array value.

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtor(). Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
uiArrayThe parent array value to add a child value to. The return index from uiJsonBuildMakeArray().
uiAddThe index of the value to add as a child of uiParent.
Returns
Returns an index reference to the created value. Exception thrown on fatal error.

Definition at line 550 of file builder.c.

◆ uiJsonBuildAddToObject()

aint uiJsonBuildAddToObject ( void *  vpBuildCtx,
aint  uiObject,
aint  uiKey,
aint  uiAdd 
)

Add a child value to a parent object value.

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtor(). Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
uiObjectThe parent object value to add a child value to. The return index from uiJsonBuildMakeObject().
uiKeyMust the index of a string object defining the object's member key.
e.g. uiKey = uiJsonBuilderStringA(vpBuildCtx, "my key");
uiAddThe index of the value to add as a child of uiParent.
Returns
Returns an index reference to the created value. Exception thrown on fatal error.

Definition at line 479 of file builder.c.

◆ uiJsonBuildMakeArray()

aint uiJsonBuildMakeArray ( void *  vpBuildCtx)

Makea JSON array value.

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtof(); Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
Returns
Returns an index reference to the created value.

Definition at line 459 of file builder.c.

◆ uiJsonBuildMakeFalse()

aint uiJsonBuildMakeFalse ( void *  vpBuildCtx)

Make a JSON false value.

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtof(); Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
Returns
Returns an index reference to the created value.

Definition at line 417 of file builder.c.

◆ uiJsonBuildMakeNull()

aint uiJsonBuildMakeNull ( void *  vpBuildCtx)

Make a JSON null value.

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtof(); Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
Returns
Returns an index reference to the created value.

Definition at line 431 of file builder.c.

◆ uiJsonBuildMakeNumberF()

aint uiJsonBuildMakeNumberF ( void *  vpBuildCtx,
double  dNumber 
)

Make a JSON floating point number value.

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtor(). Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
dNumberThe floating point number to make a JSON value from.
Returns
Returns an index reference to the created value.

Definition at line 336 of file builder.c.

◆ uiJsonBuildMakeNumberS()

aint uiJsonBuildMakeNumberS ( void *  vpBuildCtx,
int64_t  iNumber 
)

Make a JSON signed integer number value.

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtor(). Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
iNumberThe signed integer to make a JSON value from. If iNumber >= 0, an unsigned integer value will be created.
Returns
Returns an index reference to the created value.

Definition at line 358 of file builder.c.

◆ uiJsonBuildMakeNumberU()

aint uiJsonBuildMakeNumberU ( void *  vpBuildCtx,
uint64_t  uiNumber 
)

Make a JSON unsigned integer number value.

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtor(). Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
uiNumberThe unsigned integer to make a JSON value from.
Returns
Returns an index reference to the created value.

Definition at line 383 of file builder.c.

◆ uiJsonBuildMakeObject()

aint uiJsonBuildMakeObject ( void *  vpBuildCtx)

Make a JSON object value.

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtor(). Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
Returns
Returns an index reference to the created value.

Definition at line 445 of file builder.c.

◆ uiJsonBuildMakeStringA()

aint uiJsonBuildMakeStringA ( void *  vpBuildCtx,
const char *  cpString 
)

Make a string value from a null-terminated ASCII string.

Note that the input is raw UTF-32, 32-bit code points.

Note that the input must be a valid RFC8259-compliant string. Be especially careful since the input argument is a C-language string which must result in a RFC8259-compliant string. In particular, this means the the reverse solidus, "\", must always be escaped. For example:

  • intended JSON string: "I want a line feed, \n, a quote, \", and the Unicode code point \u00FF." - C-language string input: "I want a line feed, \n, a quote, \", and the Unicode code point \\u00FF."

Also note that this means the characters 0x00-0x1F must be escaped, e.g. \u0000 or \u00FF, and that characters 0x80-0xFF must be either escaped or UTF-8 encoded. Example, the character value 0xFF can be input with either of these C-language strings.

  • "\\u00FF" or
  • "\xC3\xBF"
Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtor(). Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
cpStringPointer to the string to make into a value. String may be empty but not NULL.
Returns
Returns an index reference to the created value. Exception thrown on fatal error.

Definition at line 283 of file builder.c.

◆ uiJsonBuildMakeStringU()

aint uiJsonBuildMakeStringU ( void *  vpBuildCtx,
const uint32_t *  uipData,
aint  uiLength 
)

Make a string value from UTF-32 code points.

Note that the input is raw UTF-32, 32-bit code points.

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtor(). Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
uipDataPointer to the array of Unicode UTF-32 code points. May be NULL for empty array (uiLength ignored.)
uiLengthThe number of code points in the array. May be zero.
Returns
Returns an index reference to the created value. Exception thrown on fatal error.

Definition at line 223 of file builder.c.

◆ uiJsonBuildMakeTrue()

aint uiJsonBuildMakeTrue ( void *  vpBuildCtx)

Make a JSON true value.

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtor(). Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
Returns
Returns an index reference to the created value.

Definition at line 403 of file builder.c.

◆ uiJsonIteratorCount()

aint uiJsonIteratorCount ( void *  vpIteratorCtx)

Find the number of values in the list represented by this iterator.

Parameters
vpIteratorCtxA valid context pointer returned from any of the iterator-generating functions. If invalid the application will silently exit with a BAD_CONTEXT exit code.
Returns
The number of values in the list.

Definition at line 691 of file json.c.

◆ vJsonBuildClear()

void vJsonBuildClear ( void *  vpBuildCtx)

Clears all memory associated with this builder object.

Reset this object for building a new value tree.

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtor(). Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.

Definition at line 184 of file builder.c.

◆ vJsonBuildDtor()

void vJsonBuildDtor ( void *  vpBuildCtx)

The builder object destructor.

Frees all memory allocations associated with this object. Note however, that vJsonDtor(), the parent object destructor, will free all memory associated with this builder object,

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtor(). Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.

Definition at line 154 of file builder.c.

◆ vJsonDisplayInput()

void vJsonDisplayInput ( void *  vpCtx,
abool  bShowLines 
)

Display the input JSON byte stream.

This will use a format object to display the JSON input byte stream in a hexdump-style format.

Parameters
vpCtxPointer to a valid parser context previously returned from vpJsonCtor. If invalid the application will silently exit with a BAD_CONTEXT exit code.
bShowLines- if true, the display will show a separate hexdump-type display for each line.

Definition at line 365 of file json.c.

◆ vJsonDisplayValue()

void vJsonDisplayValue ( void *  vpCtx,
json_value *  spValue,
aint  uiDepth 
)

Display a value and optionally the values in the branch below, if any.

Parameters
vpCtxPointer to a valid parser context previously returned from vpJsonCtor. If invalid the application will silently exit with a BAD_CONTEXT exit code.
spValue- pointer to value to display
uiDepth- Indicates the tree depth of the value's sub branch to display. Use zero(0) to display the full sub-tree, one(1) to display just the given value.
Returns
APG_SUCCESS if successful, APG_FAILURE otherwise.

Definition at line 412 of file json.c.

◆ vJsonDtor()

void vJsonDtor ( void *  vpCtx)

The JSON Parser component destructor.

Clears the context to prevent accidental use after release and frees all memory allocated by this object. Freed memory includes any and all memory that may have been allocated to iterator or builder objects.

Parameters
vpCtxPointer to a valid parser context previously returned from vpJsonCtor. A NULL pointer is silently ignored. However, a non-NULL pointers must be a valid JSON context pointer.

Definition at line 165 of file json.c.

◆ vJsonIteratorDtor()

void vJsonIteratorDtor ( void *  vpIteratorCtx)

The JSON iterator destructor.

Can be called to clean up all memory allocations used by this iterator. However, the JSON destructor vJsonDtor() will free all memory associated with the JSON object, including all iterators and builders.

Parameters
vpIteratorCtxA valid context pointer returned from any of the iterator-generating functions.

NULL is silently ignored. However, if non-NULL must be valid. If invalid the application will silently exit with a BAD_CONTEXT exit code.

Returns
void. Frees all memory associated with this iterator object.

Definition at line 591 of file json.c.

◆ vpJsonBuild()

void* vpJsonBuild ( void *  vpBuildCtx,
aint  uiRoot 
)

Build the JSON object.

Build a tree of values, from the collection of values "added" with uiJsonBuilderAdd() calls.

Parameters
vpBuildCtxA context pointer returned from a previous call to vpJsonBuildCtor(). Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
uiRootIndex of the value to use as the tree root. Must be a return value from one of the uiJsonBuildMake...() functions.
Returns
Pointer to an iterator over the built tree of values.

Definition at line 603 of file builder.c.

◆ vpJsonBuildCtor()

void* vpJsonBuildCtor ( void *  vpJsonCtx)

The builder object constructor.

Parameters
vpJsonCtx- Pointer to a valid JSON object previously created with vpJsonCtor(). Silently exits the application with exit code BAD_CONTEXT if pointer is invalid.
Returns
Pointer to the buider object context. If NULL, a memory allocation error has occurred.

Definition at line 124 of file builder.c.

◆ vpJsonChildren()

void* vpJsonChildren ( void *  vpCtx,
json_value *  spValue 
)

Initialize the iterator over the children of the given value as the parent node.

Parameters
vpCtxPointer to a valid parser context previously returned from vpJsonCtor. If invalid the application will silently exit with a BAD_CONTEXT exit code.
spValuePointer to the tree value to use at the root node of the walk.
Returns
Initializes an iterator for a horizontal walk of the sibling children of the root value. Walks the children left to right. Returns NULL if the value has no children.

Definition at line 530 of file json.c.

◆ vpJsonCtor()

void* vpJsonCtor ( exception spEx)

The JSON constructor.

Parameters
spExPointer to a valid exception structure initialized with XCTOR(). If not valid the application will silently exit with a BAD_CONTEXT exit code.
Returns
Pointer to the object context on success.

Definition at line 115 of file json.c.

◆ vpJsonFindKeyA()

void* vpJsonFindKeyA ( void *  vpCtx,
const char *  cpKey,
json_value *  spValue 
)

Find JSON values with a specified ASCII key.

Search for all values with the specified key.

Parameters
vpCtxPointer to a valid parser context previously returned from vpJsonCtor. If invalid the application will silently exit with a BAD_CONTEXT exit code.
cpKeyThe key as a null-terminated ASCII string.
spValue- Pointer to the root node of the sub-tree to search. The given node and all nodes in the sub-tree below, if any, will be searched.
Returns
A pointer to an iterator for the values with the specified key. NULL if no key matches are found.

Definition at line 434 of file json.c.

◆ vpJsonFindKeyU()

void* vpJsonFindKeyU ( void *  vpCtx,
const uint32_t *  uipKey,
aint  uiLength,
json_value *  spValue 
)

Find JSON values with the specified 32-bit Unicode key.

Search for all values with the specified key.

Parameters
vpCtxPointer to a valid parser context previously returned from vpJsonCtor. If invalid the application will silently exit with a BAD_CONTEXT exit code.
uipKeyPointer to the array of key string Unicode code points.
uiLengthThe number of code points in the string.
spValuePointer to the root node of the sub-tree to search. The given value and all values in the sub-tree below, if any, will be searched.
Returns
A pointer to an iterator for the values with the specified key. NULL if no key matches are found.

Definition at line 474 of file json.c.

◆ vpJsonReadArray()

void* vpJsonReadArray ( void *  vpCtx,
uint8_t *  ucpData,
aint  uiDataLen 
)

The JSON array reader.

Reads a an array containing JSON text in UTF-8 format and parses the file into a value tree.

Parameters
vpCtxPointer to a valid parser context previously returned from vpJsonCtor. If invalid the application will silently exit with a BAD_CONTEXT exit code.
ucpDataPointer to the UTF-8 encoded JSON text.
uiDataLenThe number of bytes of JSON text data.
Returns
Returns an iterator to the values in the value tree. The order of values is that of a depth-first walk of the value tree.

Definition at line 289 of file json.c.

◆ vpJsonReadFile()

void* vpJsonReadFile ( void *  vpCtx,
const char *  cpFileName 
)

The JSON file reader.

Reads a file containing JSON text in UTF-8 format and parses the file into a value tree.

Parameters
vpCtxPointer to a valid parser context previously returned from vpJsonCtor. If invalid the application will silently exit with a BAD_CONTEXT exit code.
cpFileNameThe name of the file to read.
Returns
Returns an iterator to the values in the value tree. The order of values is that of a depth-first walk of the value tree.

Definition at line 207 of file json.c.

◆ vpJsonTree()

void* vpJsonTree ( void *  vpCtx,
json_value *  spValue 
)

Initialize the iterator to walk a value tree.

"Walk" refers to a depth-first traversal of the value tree.

Parameters
vpCtxPointer to a valid parser context previously returned from vpJsonCtor. If invalid the application will silently exit with a BAD_CONTEXT exit code.
spValuePointer to the start value. The given value and all values in the sub-tree below, if any, will be walked.
Returns
An initialized iterator to the first node. In this case it is the root node or spValue.

Definition at line 501 of file json.c.

APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.