JSON schema to PL/I mapping
The DFHJS2LS utility program supports mappings between JSON schemas and PL/I data structures. Because the Enterprise PL/I compiler and older PL/I compilers differ, two language options are supported: PLI-ENTERPRISE and PLI-OTHER.
Rules for mapping schema element names to PL/I
- Characters other than A-Z, a-z, 0-9, @, #, _, or $ are replaced
with '
X
'.
For example, monthly-total becomes monthlyXtotal.
You
can use the
MAPPING-OVERRIDES
parameter to change the way other characters are
handled. For example, if you set the value
HYPHENS-AS-UNDERSCORES
, any hyphen
in the JSON schema is converted to an underscore instead of an X.
For example,
monthly-total
becomes
monthly_total.

- Duplicate names in the same scope are made unique by the addition
of one or two numeric digits to the second and subsequent
instances
of the name.
For example, three instances of year become year , year1 , and year2.
- A JSON schema specifies that a variable has varying cardinality
if it has a
"type"
value of
"array"
,
and the keywords
"minItems"
and
"maxItems"
are
omitted or have different values. If the schema specifies that the
variable has varying cardinality, then field names are created
with
suffixes of
"_cont"
and
"_num".
For more information, see Variable arrays of elements in DFHJS2LS.
- A JSON schema specifies that a variable is optional if it does not appear in the "required" keyword array that is associated with the enclosing JSON schema "object" type. For optional fields, an additional field is generated with a suffix of _num added to the element name. At run time this is zero to indicate the value was absent from the JSON data, and non-zero if the value was present in the JSON data.
- Field names are limited to 31 characters. If a generated name, including any prefix and suffix, exceeds this length, the element name is truncated.
Rules for mapping schema types to PL/I
- If the MAPPING-LEVEL parameter is set to 1.2 or higher and the CHAR-VARYING parameter is set to NULL, variable-length character data is mapped to null-terminated strings and an extra character is allocated for the null-terminator.
- If the MAPPING-LEVEL parameter is set to 1.2 or higher and the CHAR-VARYING parameter is not specified, by default variable-length character data is mapped to a VARYINGZ data type for Enterprise PL/I and VARYING data type for Other PL/I.
- Variable-length binary data is mapped to a VARYING data type if it less than 32 768 bytes and to a container if it is more than 32 768 bytes.
| JSON Schema keyword | PL/I data description |
|---|---|
All
of:
|
Not supported |
|
This keyword is ignored, but it is assumed to be compatible with the draft 04 JSON Schema specification. |
|
These keywords are ignored. |
|
The "format" keyword is used to modify either the generated structure or run-time value. See the following information for the supported use of "format". |
|
The only form of JSON array currently supported is a repeated number of same type values. The <JSON Sub-schema> must define a supported "type" , but that "type" cannot be "array". This is a restriction on the language structure generated. "additionalItems" is assumed to be false, and no other value is supported. If both "minItems" and "maxItems" are present, and they are equal, then the array is treated as fixed cardinality, otherwise it is treated as varying cardinality. See Variable arrays of elements in DFHJS2LS. |
|
"uniqueItems" is not supported with JSON arrays. The <JSON Sub-schema> must define a supported "type" , but that "type" cannot be "array" . This is a restriction on the language structure generated. |
|
The only form of JSON object currently supported is a fixed set of named elements. This will generate a structure (or sub-structure) using the element names. "additionalProperties" is assumed to be false , and no other value is supported. Any element in the "properties" object is considered "optional" if it is not in the "required" array or if no "required" array exists. An "optional" element is given a variable ordinality of zero to X; where X is either 1 or the maximum number of items in the array, where that item is defined as an array. See Variable arrays of elements in DFHJS2LS. |
|
None of these keywords are supported with JSON objects. |
|
char[ z ] where the value of z is based on m , but dependent on the settings of the CHAR-VARYING parameter. m is based on the "maxLength" keyword and treated as fixed length string. "pattern" and "minLength" restrictions are passed through to the language structure only as a comment. |
|
When CCSID=1200 at mapping level 4.0 and higher: WIDECHAR( z ) where the value of z is based on m , but dependent on the settings of the CHAR-VARYING parameter. m is based on the "maxLength " keyword and treated as fixed length string. |
|
FIXED DECIMAL (15,0) All supported when DATETIME=PACKED15 |
|
CHAR( m ) where m is based on the "maxLength" keyword and treated as fixed length string. When CCSID=1200 at mapping level 4.0 and higher: WIDECHAR( m ) where m is based on the "maxLength" keyword and treated as fixed length string. |
|
CHAR( m ) where m is based on the "maxLength" keyword. |
|
CHAR( m ) where m is based on the "maxLength" keyword. |
|
CHAR( m ) where m is based on the "maxLength" keyword and treated as a fixed length string, and <predefined> is one of: email , hostname , ipv4 or ipv6. A relevant "pattern" is passed to the comment. When CCSID=1200 at mapping level 4.0 and higher: WIDECHAR( m ) where m is based on the "maxLength" keyword and treated as fixed length string, and where <predefined> is one of: email , hostname , ipv4 , or ipv6 . A relevant "pattern" is used and passed to the comment. |
|
Mapping level 1.1 and lower:
Mapping level 1.2 and higher:
where BIT(7) is provided for alignment and BIT(1) contains the Boolean mapped value. |
|
"maxExclusive" and "minExclusive" restrictions are passed to the language structure only as a comment. "multipleOf" is ignored. |
|
|
|
|
|
|
|
|
|
|
|
Mapping level 1.1 and lower:
Mapping level 1.2 and higher:
All mapping levels:
|
|
Mapping level 1.1 and lower:
Mapping level 1.2 and higher:
All mapping levels:
|
|
Mapping level 1.1 and lower:
Mapping level 1.2 and higher:
|
|
FIXED DECIMAL( n , m ) |
|
Mapping levels 1.0 and 1.1:
Mapping level 1.2 and higher:
Note: The IBM® Hexadecimal Floating Point
(HFP) data representation is not exactly the same as the IEEE-754-1985 representation used for JSON.
Some values may not convert exactly from one representation to the other. Some extremely large or
small values might not be valid for float data types. Some values may lose precision when converted
to or from HFP representation. If precise conversions are important, consider replacing use of
DECIMAL FLOAT data types with fixed precision alternatives.
|
|
Mapping levels 1.0 and 1.1:
Mapping level 1.2 and higher:
Note: The IBM Hexadecimal Floating Point
(HFP) data representation is not exactly the same as the IEEE-754-1985 representation used for JSON.
Some values may not convert exactly from one representation to the other. Some extremely large or
small values might not be valid for float data types. Some values may lose precision when converted
to or from HFP representation. If precise conversions are important, consider replacing use of
DECIMAL FLOAT data types with fixed precision alternatives.
|