Previous Topic Next topic Print topic


Appendix B - JSON Output Text

The JSON generation process converts each eligible elementary data item within identifier-2, unless it has been suppressed, to character format. Only the first definition of each storage area is processed.

The following elementary data items are not eligible:

  • Redefined data items
  • Date items defined by RENAMES clause
  • Table items that have zero occurrences
    Note: If one or more zero occurrence tables are the only subordinate data items in their containing (immediately superordinate) group, the containing group item is included in the JSON text with the special value null.

For information about the format conversion of elementary data, see Appendix D - Format Conversion of Elementary Data and Appendix E - Trimming of Generated JSON Data. The JSON names are obtained from the NAME phrase if specified; otherwise by default they are derived from the data-names within identifier-2 as described in Appendix F - JSON Name Formation.

The names of group items that contain the selected elementary items are retained as the names of parent JSON objects.

No extra white space (new lines, indentation, and so forth) is inserted to make the generated JSON text more readable.

If identifier-1 (the target area) is not large enough to contain the JSON text after generation, an exception condition exists. Use the ON EXCEPTION phrase to control processing in the event of an exception; see The JSON GENERATE Statement for more details.

If identifier-1 is larger than the JSON text, any existing data beyond the size of the JSON text will remain in identifier-1 after the JSON GENERATE statement. To avoid referring to that data, either initialize identifier-1 to spaces before the JSON GENERATE statement or specify the COUNT phrase.

If you use the COUNT phrase, after successful execution of the JSON GENERATE statement, identifier-3 contains the total number of character positions (UTF-16 encoding units or bytes) that were generated. Use this value as a reference modification length field to refer to the part of identifier-2 that contains the generated JSON text.

After execution of the JSON GENERATE statement, special register JSON-CODE contains either zero, which indicates successful completion, or a nonzero exception code. For details, see JSON-CODE Exception Codes.

A byte order mark is not generated for JSON texts.

Previous Topic Next topic Print topic