JSON Schema to COBOL mapping
The JSON web services assistant with parameters MAPPING-MODE=JS2LS
and LANG=COBOL
will
map between JSON Schema and COBOL data structures.
- COBOL reserved words are prefixed with '
X
'.For example,
DISPLAY
becomesXDISPLAY
. - Characters other than A-Z, a-z, 0-9, or hyphen are replaced with
'
X
'.For example,
monthly_total
becomesmonthlyXtotal
. - If the last character is a hyphen, it is replaced with '
X
'.For example,
ca-request-
becomesca-requestX
. - 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
becomeyear
,year1
, andyear2
. - 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 with MAPPING-MODE=JS2LS.
- 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 28 characters. If a generated name, including the prefix and suffix, exceeds this length, the element name is truncated.
"textString": {
"type":"string",
"maxLength":10000,
"minLength":1
}
maps to:15 textString-length PIC S9999 COMP-5 SYNC
15 textString PIC X(10000)
JSON Schema keyword | COBOL 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 runtime value. See the information later in this table for the supported use of "format". |
|
The only form of JSON array currently
supported is a repeated number of same type values. The
If both |
|
|
|
The only form of JSON object that is currently supported is a fixed set of named elements. This generates a structure (or sub-structure) that uses the element names.
Any
element in the |
|
None of these keywords are supported with JSON objects. |
|
where the value of z is based on m, but dependent on the settings of the CHAR-VARYING parameter. m is
based on the
|
|
When CCSID=1200:
where the value of z is based on m, but dependent on the settings of the CHAR-VARYING parameter. m is based on the |
|
PIC S9(15) COMP-3 All supported when DATETIME=PACKED15 Note that |
|
where m is
based on the When CCSID=1200:
where m is
based on the |
|
where m is
based on the |
|
where m is
based on the |
|
where m is
based on the When CCSID=1200:
where m is
based on the |
|
The
value |
|
|
|
or
where 10(z-1) < m <= 10z |
|
or
where 10(z-1) < m <= 10z |
|
or
where 10(z-1) < m <= 10z |
|
or
where 10(z-1) < m <= 10z |
|
|
|
where p and n are default values. |
|
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 might
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 might lose precision when converted to or from HFP representation. If precise conversions are important, consider replacing use of COMP-1 data types with fixed precision alternatives. |
|
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 might
not convert exactly from one representation to the other.
Some extremely large or small values might not be valid for double data types. Some values might lose precision when converted to or from HFP representation. If precise conversions are important, consider replacing use of COMP-2 data types with fixed precision alternatives. |
minimum
and maximum
keywords:- For signed types (
short
,int
, andlong
), DISPLAY is used when the following are specified:
where"maximum":a "minimum":-a
a
is a string of '9's. - For unsigned types (
unsignedShort
,unsignedInt
, andunsignedLong
), DISPLAY is used when the following are specified:
where"maximum":a "minimum":0
a
is a string of '9's.