JSON_PAR (RPGLE)
JSON ParserMore ....
Procedures [top]
| abortParsing |
Abort parsing |
| back |
Move parser back |
| json_parse |
exported
Parse JSON string |
| more |
Checks for more characters in string |
| next |
Next character |
| nextArray |
Next JSON array |
| nextCleanChar |
Next clean character |
| nextString |
Next string |
| nextValue |
Next value |
Copybooks [top]
| JSON_C |
|
| JSON_H |
|
Detailed Description [top]
A utility module for parsing JSON strings.The parser string should be a valid JSON string or else and escape message will be sent to the caller.
The parser also accepts the equal sign (=) as a separator for the key and the value. The parser also supports the ; instead of the , for separating pairs of values or values in an array. Strings may be enclosed in single or double quotes. Arrays can either be enclosed in curly braces () or in brackets []. Empty objects and arrays are supported. Unicode representation of a character is not supported like \u00CF.
- Author:
- Mihael Schmidt
- Date:
- 2009-03-07
- Links:
- JSON.org
- Infos:
- The JSON syntax is not fully supported at the moment.
Procedure Documentation [top]
abortParsing [top]
The memory of the parser header is deallocated (freed) and an escape message is sent to the previous call stack entry with the passed message text.
- Parameters:
-
Pointer — Pointer to parser header Character (1000) — Message text
back [top]
Moves the position of the parser back by one position.
- Parameters:
-
Pointer — Pointer to parser header structure
json_parse [top]
Creates a JSON object from the passed string. If the passed string is not a valid JSON string an escape message will be sent. The string must be null terminated.
- Parameters:
-
Pointer — Pointer to JSON string Pointer — Pointer to parser header (only for internal use)
- Return value:
-
Pointer — Pointer to JSON object
- Exported.
more [top]
Checks if there are still more characters to parse in the given string.
- Parameters:
-
Pointer — Pointer to the rest of the JSON string to be parsed
next [top]
Returns the next character in the JSON string and moves the parser forward by one position.
- Parameters:
-
Pointer — Pointer to parser header structure
- Return value:
-
Character (1) — next character or null if there are no more characters
nextArray [top]
Returns the JSON array which is at the next position in the JSON string. This procedure expects the position of the parser to be on the opening bracket of the array ( [ ). If there is no JSON array array at the current position an escape message will be sent.
Empty arrays are also supported.
Empty arrays are also supported.
- Parameters:
-
Pointer — Pointer to the parser header structure
- Return value:
-
Pointer — Pointer to JSON array
nextCleanChar [top]
Moves the parser to the position on the next clean character and returns it to the caller. Character like carriage return, linefeed and blanks are ignored. On a null character an escape message will be sent.
- Parameters:
-
Pointer — Pointer to the parser header structure
- Return value:
-
Character (1) — next clean character
nextString [top]
Returns the next string from the current parser position on and moves the parser to the position behind the returned string.
- Parameters:
-
Pointer — Pointer to the parser header structure Character (1) — Open quote character of the string (' or ")
- Return value:
-
Character (10000) — next JSON string
nextValue [top]
Returns the next value. The parser is moved after the next value. The returned value can be any supported JSON data type including array and object.
- Parameters:
-
Pointer — Pointer to the return value data structure Pointer — Pointer to the JSON string Numeric (Integer) (10) — JSON data type of the return value