JSON_UTIL (RPGLE)

JSON : Utilities
Details ....

Copybooks  

'json_h.rpgle'
'json_int_h.rpgle'
'ifsio_h.rpgle'
'libc_h.rpgle'
'ceeapi_h.rpgle'
'arraylist_h.rpgle'
QSYSINC/QRPGLESRC,QUSEC
COMMON STRUCTURE FOR ERROR CODE PARAMETER
'json_c.rpgle'

Procedures  

extractNumber
Convert record data to an edited number.
jsona_util_getDateexported
Get date entry
jsona_util_getDecimalexported
Get decimal entry
jsona_util_getTimeexported
Get time entry
jsona_util_getTimestampexported
Get timestamp entry
jsona_util_putDateexported
Add date entry
jsona_util_putDecimalexported
Add decimal entry
jsona_util_putTimeexported
Add time entry
jsona_util_putTimestampexported
Add timestamp entry
json_util_dsToJsonObjectexported
Convert a data structure to a JSON object
json_util_fromFileexported
Read JSON from stream file
json_util_getDateexported
Get date entry
json_util_getDecimalexported
Get decimal entry
json_util_getTimeexported
Get time entry
json_util_getTimestampexported
Get timestamp entry
json_util_putDateexported
Add date entry
json_util_putDecimalexported
Add decimal entry
json_util_putTimeexported
Add time entry
json_util_putTimestampexported
Add timestamp entry
json_util_toFileexported
Output JSON Object to stream file

Detailed Description  

Utilities module for the JSON service program.
Author:
Mihael Schmidt
Date:
31.01.2010
Changes:
01.08.2010   —   Mihael Schmidt
added date data type support

26.11.2010   —   Mihael Schmidt
added toFile/fromFile procedures

09.04.2011   —   Mihael Schmidt
added decimal data type support

06.05.2011   —   Mihael Schmidt
Switch from Linked List to ArrayList

24.06.2011   —   Brian Garland
added time and timestamp procedures, added dataStructure to JSON object procedure

Links:
http://www.rpgnextgen.com
http://www.json.org

Procedure Documentation  

extractNumber  

ZeichenextractNumber(Pointer, Zeichen, Zeichen, Gepackt, Gepackt)
This makes it easy to extract zoned and packed fields from a substring of a record.
Parameter:
Pointer   valueField pointer
Zeichen (1)   valueEdit code
Zeichen (10)   valueField type (*ZONED or *PACKED)
Numerisch (Gepackt) (2,0)   valueNumber of digits
Numerisch (Gepackt) (2,0)   valueNumber of decimal places
Return value:
Zeichen (256)String containing edited value
Author:
Brian Garland

jsona_util_getDate  

Datumjsona_util_getDate(Pointer, ohne Vorzeichen)
A convenience procedure for getting a date from a string entry. The string must be in *ISO format (yyyy-mm-dd).

If the entry is not of type string or the entry is not a date string in *ISO format an escape message will be sent.
Parameter:
Pointer   constPointer to the JSON array
Numerisch (ohne Vorzeichen) (10)   constIndex
Return value:
DatumDate
Exported.
Author:
Mihael Schmidt
Date:
01.08.2010

jsona_util_getDecimal  

Gepacktjsona_util_getDecimal(Pointer, ohne Vorzeichen)
A convenience procedure for getting a decimal value from a string entry.

If the entry is not of type string or the entry is not a number an escape message will be sent.
Parameter:
Pointer   constPointer to the JSON array
Numerisch (ohne Vorzeichen) (10)   constIndex
Return value:
Numerisch (Gepackt) (30,10)Decimal value
Exported.
Author:
Mihael Schmidt
Date:
09.04.2011

jsona_util_getTime  

Zeitjsona_util_getTime(Pointer, ohne Vorzeichen)
A convenience procedure for get a time from a string entry. The string must be in *ISO format (hh.mm.ss).

If the entry is not of type string or the entry is not a time string in *ISO format an escape message will be send.
Parameter:
Pointer   constPointer to the JSON array
Numerisch (ohne Vorzeichen) (10)   constIndex
Return value:
ZeitTime
Exported.
Author:
Brian Garland
Date:
2011-06-24

jsona_util_getTimestamp  

Zeitstempeljsona_util_getTimestamp(Pointer, ohne Vorzeichen)
A convenience procedure for get a timestamp from a string entry. The string must be in *ISO format (yyyy-mm-dd-hh.mm.ss.mmmmmm).

If the entry is not of type string or the entry is not a timestamp string in *ISO format an escape message will be send.
Parameter:
Pointer   constPointer to the JSON array
Numerisch (ohne Vorzeichen) (10)   constIndex
Return value:
ZeitstempelTimestamp
Exported.
Author:
Brian Garland
Date:
2011-06-24

jsona_util_putDate  

voidjsona_util_putDate(Pointer, Datum, ohne Vorzeichen)
Convenience procedure for adding a date string in *ISO format to the JSON array.
Parameter:
Pointer   constPointer to the JSON array
Datum   constDate
Numerisch (ohne Vorzeichen) (10)   const   optionalIndex (default: last)
Exported.
Author:
Mihael Schmidt
Date:
01.08.2010

jsona_util_putDecimal  

voidjsona_util_putDecimal(Pointer, Gepackt, Gepackt, ohne Vorzeichen)
Convenience procedure for adding a decimal value as a string to the JSON array.
Parameter:
Pointer   constPointer to the JSON array
Numerisch (Gepackt) (30,10)   constDecimal value
Numerisch (Gepackt) (2,0)   const   optional   omissibleDecimal positions (default: 2)
Numerisch (ohne Vorzeichen) (10)   const   optionalIndex (default: last)
Exported.
Author:
Mihael Schmidt
Date:
12.04.2011

jsona_util_putTime  

voidjsona_util_putTime(Pointer, Zeit, ohne Vorzeichen)
Convenience procedure for adding a time string in *ISO format to the JSON array.
Parameter:
Pointer   constPointer to the JSON array
Zeit   constTime
Numerisch (ohne Vorzeichen) (10)   const   optionalIndex (default: last)
Exported.
Author:
Brian Garland
Date:
2011-06-24

jsona_util_putTimestamp  

voidjsona_util_putTimestamp(Pointer, Zeitstempel, ohne Vorzeichen)
Convenience procedure for adding a timestamp string in *ISO format to the JSON array.
Parameter:
Pointer   constPointer to the JSON array
Zeitstempel   constTimestamp
Numerisch (ohne Vorzeichen) (10)   const   optionalIndex (default: last)
Exported.
Author:
Brian Garland
Date:
2011-06-24

json_util_dsToJsonObject  

Pointerjson_util_dsToJsonObject(Zeichen, Zeichen)
Parameter:
Zeichen (65535)   variable sizeData structure
Zeichen (20)   constQualified file name that the data structure is based upon (10A filename + 10A library)
Return value:
PointerJSON object
Exported.
Author:
Brian Garland
Infos:
  Varying fields with a 4-byte header are not supported.

json_util_fromFile  

Pointerjson_util_fromFile(Zeichen, Boolean)
Parameter:
Zeichen (1024)   constStream file path
Boolean   const   optionalDelete file after reading (optional)
Return value:
PointerJSON object
Exported.

json_util_getDate  

Datumjson_util_getDate(Pointer, Zeichen)
A convenience procedure for getting a date from a string entry. The string must be in *ISO format (yyyy-mm-dd).

If the entry is not of type string or the entry is not a date string in *ISO format an escape message will be sent.
Parameter:
Pointer   constPointer to the JSON object
Zeichen (65535)   const   variable sizeKey
Return value:
DatumDate
Exported.
Author:
Mihael Schmidt
Date:
01.08.2010

json_util_getDecimal  

Gepacktjson_util_getDecimal(Pointer, Zeichen)
A convenience procedure for getting a decimal value from a string entry.

If the entry is not of type string or the entry is not a number an escape message will be sent.
Parameter:
Pointer   constPointer to the JSON object
Zeichen (65535)   const   variable sizeKey
Return value:
Numerisch (Gepackt) (30,10)Decimal value
Exported.
Author:
Mihael Schmidt
Date:
09.04.2011

json_util_getTime  

Zeitjson_util_getTime(Pointer, Zeichen)
A convenience procedure for get a time from a string entry. The string must be in *ISO format (hh.mm.ss).

If the entry is not of type string or the entry is not a time string in *ISO format an escape message will be send.
Parameter:
Pointer   constPointer to the JSON object
Zeichen (65535)   const   variable sizeKey
Return value:
ZeitTime
Exported.
Author:
Brian Garland
Date:
2011-06-24

json_util_getTimestamp  

Zeitstempeljson_util_getTimestamp(Pointer, Zeichen)
A convenience procedure for get a timestamp from a string entry. The string must be in *ISO format (yyyy-mm-dd-hh.mm.ss.mmmmmm).

If the entry is not of type string or the entry is not a timestamp string in *ISO format an escape message will be send.
Parameter:
Pointer   constPointer to the JSON object
Zeichen (65535)   const   variable sizeKey
Return value:
ZeitstempelTimestamp
Exported.
Author:
Brian Garland
Date:
2011-06-24

json_util_putDate  

voidjson_util_putDate(Pointer, Zeichen, Datum)
Convenience procedure for adding a date string in *ISO format to the json object.
Parameter:
Pointer   constPointer to the JSON object
Zeichen (65535)   const   variable sizeKey
Datum   constDate
Exported.
Author:
Mihael Schmidt
Date:
2010-08-01

json_util_putDecimal  

voidjson_util_putDecimal(Pointer, Zeichen, Gepackt, Gepackt)
Convenience procedure for adding a decimal value as a string to the json object.
Parameter:
Pointer   constPointer to the JSON object
Zeichen (65535)   const   variable sizeKey
Numerisch (Gepackt) (30,10)   constDecimal value
Numerisch (Gepackt) (2,0)   const   optionalDecimal positions (default: 2)
Exported.
Author:
Mihael Schmidt
Date:
09.04.2011

json_util_putTime  

voidjson_util_putTime(Pointer, Zeichen, Zeit)
Convenience procedure for adding a time string in *ISO format to the json object.
Parameter:
Pointer   constPointer to the JSON object
Zeichen (65535)   const   variable sizeKey
Zeit   constTime
Exported.
Author:
Brian Garland
Date:
2011-06-24

json_util_putTimestamp  

voidjson_util_putTimestamp(Pointer, Zeichen, Zeitstempel)
Convenience procedure for adding a timestamp string in *ISO format to the json object.
Parameter:
Pointer   constPointer to the JSON object
Zeichen (65535)   const   variable sizeKey
Zeitstempel   constTimestamp
Exported.
Author:
Brian Garland
Date:
2011-06-24

json_util_toFile  

voidjson_util_toFile(Pointer, Zeichen, Integer, Boolean)
Parameter:
Pointer   constJSON Object
Zeichen (1024)   constStream file path
Numerisch (Integer) (10)   const   optional   omissibleCCSID (optional)
Boolean   const   optional   omissibleDelete if file exist (optional)
Exported.