JSON (RPGLE)
JSON Service programMore ....
Procedures [top]
| disposeEntryValue |
Dealloc entry value |
| escapeLastToken |
exported
Escape characters |
| getJSONEntry |
Get entry by key |
| isJSONImpl |
Check for JSON object |
| json_abortIteration |
exported
Abort iteration |
| json_clear |
exported
Clear JSON object |
| json_contains |
exported
Contains key |
| json_create |
exported
Create JSON Object |
| json_dispose |
exported
Deallocate JSON object |
| json_get |
exported
Get entry |
| json_getArray |
exported
Get array entry |
| json_getBoolean |
exported
Get boolean entry |
| json_getDouble |
exported
Get double entry |
| json_getInt |
exported
Get integer entry |
| json_getLong |
exported
Get long entry |
| json_getNext |
exported
Get next entry |
| json_getObject |
exported
Get object entry |
| json_getString |
exported
Get string entry |
| json_isEmpty |
exported
Is JSON object empty |
| json_putArray |
exported
Add array entry |
| json_putBoolean |
exported
Add boolean entry |
| json_putDouble |
exported
Add double entry |
| json_putInt |
exported
Add integer entry |
| json_putLong |
exported
Add long entry |
| json_putNull |
exported
Add null value entry |
| json_putObject |
exported
Add JSON object entry |
| json_putString |
exported
Add character entry |
| json_remove |
exported
Remove entry |
| json_size |
exported
Count JSON object entries |
| json_toString |
exported
String representation of the JSON object in JSON syntax |
| sendDiagnosticMessage |
exported
Send diagnostic message |
| sendEscapeMessage |
exported
Send escape message |
Copybooks [top]
| JSON_H |
|
| JSON_INT_H |
|
| CEEAPI_H |
|
| LLIST_H |
|
| JSON_C |
|
Detailed Description [top]
From the main web site:JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.
JSON is built on two structures:- A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
- An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangable with programming languages also be based on these structures.
In JSON, they take on these forms:An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).
Concerning this implementation:The pointer to the JSON object will be check on every procedure call. If the pointer does not point to a JSON object an escape message will be send to the next level of the call stack.
If the JSON obect is queried for an entry of a specific type and the type does not match with the expectation of the procedure an escape message will be send to the next level of the call stack.
All the allocated memory of the JSON object and its entries is managed by this service program and will be freed with the call of the procedure dispose. No manual deallocation must be done.
Procedure Documentation [top]
disposeEntryValue [top]
- Parameters:
-
Pointer — Pointer to an entry
- Author:
- Mihael Schmidt
- Date:
- 14.05.2008
escapeLastToken [top]
The last element of the token list will be checked for characters which need to be escaped.
- Parameters:
-
Pointer — Pointer to token list
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
getJSONEntry [top]
- Parameters:
-
Pointer — Pointer to the JSON object Pointer — Pointer to the key Numeric (Unsigned) (10) — Key length
- Return value:
-
Pointer — Pointer to the entry or *null if no such entry exists in this JSON object.
isJSONImpl [top]
If the pointer does not point to a JSON object and escape message will be send to the next entry in the call stack.
- Parameters:
-
Pointer — Pointer to the JSON object
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_abortIteration [top]
- Parameters:
-
Pointer — Pointer to the JSON object
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_clear [top]
- Parameters:
-
Pointer — Pointer to the JSON object
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_contains [top]
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Entry key
- Return value:
-
Boolean — *on = JSON object contains key
*off = JSON object does not contain key
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_create [top]
The memory allocated for this object must be deallocated with the dispose procedure when finished.
- Return value:
-
Pointer — Pointer to the JSON object
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_dispose [top]
- Parameters:
-
Pointer — Pointer to the JSON object
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_get [top]
The return value is a pointer to a null terminated string so that it can be easily processed with the %str BIF.
The memory for the return value was allocated will be managed by the JSON object and will be disposed with the dispose procedure. The calling program does not need to deallocate the the memory by itself.
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Key
- Return value:
-
Pointer — Pointer to a null terminated string or *null if JSON object does not contain the passed key
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_getArray [top]
If the entry is not of type array an escape message will be send.
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Key
- Return value:
-
Pointer — Pointer to the JSON array
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_getBoolean [top]
If the entry is not of type boolean an escape message will be send.
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Key
- Return value:
-
Boolean — Boolean value of the entry
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_getDouble [top]
If the entry is not of type double an escape message will be send.
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Key
- Return value:
-
Numeric (Float) (8,) — Double value of the entry
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_getInt [top]
If the entry is not of type integer an escape message will be send.
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Key
- Return value:
-
Numeric (Integer) (10) — Integer value of the entry
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_getLong [top]
If the entry is not of type long an escape message will be send.
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Key
- Return value:
-
Numeric (Integer) (20) — Long value of the entry
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_getNext [top]
If the iteration ends with the last key *null will be returned.
If the iteration is aborted the calling program should use the abortIteration procedure to reset the iteration.
- Parameters:
-
Pointer — Pointer to the JSON object
- Return value:
-
Pointer — Pointer to the key of the next entry or *null if there are no more entries
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_getObject [top]
If the entry is not of type object an escape message will be send.
- Parameters:
-
Pointer — Pointer to the JSON array Character (65535) — Index
- Return value:
-
Pointer — Pointer to the JSON object
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 11.05.2008
json_getString [top]
If the entry is not of type string an escape message will be send.
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Key
- Return value:
-
Pointer — Pointer to a null-terminated string
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_isEmpty [top]
- Parameters:
-
Pointer — Pointer to the JSON object
- Return value:
-
Boolean — *on = JSON object is empty
*off = JSON object is not empty
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_putArray [top]
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Key Pointer — Array
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 19.04.2008
json_putBoolean [top]
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Key Boolean — Value
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_putDouble [top]
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Key Numeric (Float) (8,) — Value
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_putInt [top]
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Key Numeric (Integer) (10) — Value
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_putLong [top]
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Key Numeric (Integer) (20) — Value
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_putNull [top]
- Parameters:
-
Pointer — Pointer to the JSON array Character (65535) — Key
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 11.05.2008
json_putObject [top]
- Parameters:
-
Pointer — Pointer to the JSON array Character (65535) — Key Pointer — Pointer to the JSON object
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 11.05.2008
json_putString [top]
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Key Character (65535) — Value
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_remove [top]
- Parameters:
-
Pointer — Pointer to the JSON object Character (65535) — Entry key
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_size [top]
- Parameters:
-
Pointer — Pointer to the JSON object
- Return value:
-
Numeric (Integer) (10) — number of entries in the JSON object
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
json_toString [top]
For entries of type string double quotes and backslashes will be escaped (" => \" and \ => \\).
- Parameters:
-
Pointer — Pointer to the JSON object
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 20.03.2008
sendDiagnosticMessage [top]
- Parameters:
-
Character (200) — Message
- Exported.
- Author:
- Mihael Schmidt
- Date:
- 07.03.2009