RPG Next Gen
Wiki RSS Feed Weblog
Business picture

JSON Utilities

JSON Checker

The JSON checker module contains the JSON checker C code from the JSON.org site. It can validate a JSON string by analyzing it character by character.

The passed characters must be in ASCII (CCSID 819). The iconv program can be used to translate from a source CCSID to a destination CCSID. For easier usage take a look at the checker utilities module JSON_CUTIL.


Who still wants to use the checker module (and not the checker utilities) should stick to the following instructions:

  1. create a json_checker with the json_new_checker procedure
  2. translate the characters to CCSID 819 (via iconv) if needed
  3. pass the characters one at a time to the checker using the json_checker_char procedure (it expects not a 1A value but an unsigned integer representing the character, see further below)
  4. finally call json_checker_done to check if the string is valid

For the character conversion to an unsigned integer a data structure can be used.

D conv_ds DS D unsInt 10U 0 inz(0) D char 1A overlay(unsInt : 4)

If the json_checker_char procedure returns false (0) is has already deallocated the memory of the checker for you. You don't have to call json_checker_done anymore.