The JSON functions are used to create and manipulate JSON structures.
The JSON functions are only available in NX32L compilation mode.
The strings used with JSON must use UTF-8 encoding, so non-ASCII characters must be entered as special characters, see below.
Examples of how the JSON functions can be used can be found in the REST Example and the REST Basic Authentication Example.
The following functions are available:
|
•jsonCreateArray |
Creates a new,empty JSON array.
|
|
•jsonCreateObject |
Creates a new, empty JSON object.
|
|
•jsonFree |
Releases a JSON object or array
|
|
•jsonGetType |
Returns the type of a JSON value.
|
|
•jsonGetKey |
Iterate through a JSON object.
|
|
•jsonArraySize |
Get the size of a JSON array.
|
|
•jsonAddValue |
Adds a JSON structure to the end of a JSON array.
|
|
•jsonAddValueString |
Adds a string to the end of a JSON array.
|
|
•jsonAddValueInt |
Adds an integer to the end of a JSON array.
|
|
•jsonAddValueFloat |
Adds a floating point value to the end of a JSON array.
|
|
•jsonAddValueBool |
Adds a boolean to the end of a JSON array.
|
|
•jsonAddValueNull |
Adds a null-value to the end of a JSON array.
|
|
•jsonSetValue |
Stores a JSON structure at a specific index in a JSON array or at a specific key in a JSON object.
|
|
•jsonSetValueString |
Stores a string at a specific index in a JSON array or at a specific key in a JSON object.
|
|
•jsonSetValueInt |
Stores an integer at a specific index in a JSON array or at a specific key in a JSON object.
|
|
•jsonSetValueFloat |
Stores a floating point value at a specific index in a JSON array or at a specific key in a JSON object.
|
|
•jsonSetValueBool |
Stores a boolean at a specific index in a JSON array or at a specific key in a JSON object.
|
|
•jsonSetValueNull |
Stores a null-value at a specific index in a JSON array or at a specific key in a JSON object.
|
|
•jsonGetValue |
Reads a JSON structure from the provided JSON structure
|
|
•jsonGetString |
Reads a string from the provided JSON structure
|
|
•jsonGetInt |
Reads an integer from the provided JSON structure
|
|
•jsonGetFloat |
Reads a floating point value from the provided JSON structure
|
|
•jsonGetBool |
Reads a boolean from the provided JSON structure
|
|
•jsonDeleteValue |
Removes a value from a JSON structure.
|
|
•jsonToString |
Creates a string representation of the JSON structure.
|
|
•jsonFromString |
Creates a JSON structure from a string.
|
|
•jsonHandleStats |
Retrieves information about JSON handles, to help with detecting handle leaks.
|
Using Unicode strings
The JSON API uses Unicode strings so that any text can be in the local language rather than in English.
While it is not possible to enter Unicode text directly into a string variable, it can be done as a string of special characters (see STRING).
This approach requires 3 steps for each character:
1. Find the character at the Unicode homepage (www.unicode.org).
2. Encode the character into UTF-8 (Wikipedia gives a good description of this here: en.wikipedia.org/wiki/Utf-8).
3. Type in the special characters from step 2 (e.g. "$CF$86" for the Greek character "phi").
|