C and C++ to JSON schema mapping
The DFHLS2JS utility program supports mappings between C and C++ data types and JSON schema definitions.
- Characters that are not valid in JSON property names are replaced
with '
X
'.
For example, monthly-total becomes monthlyXtotal.
- Duplicate names are made unique by the addition of one or more
numeric digits.
For example, two instances of year become year and year1.
- Header files must contain a top level struct instance.
- You cannot declare a structure type that contains itself as a member.
- The following C and C++ data types are not supported:
- decimal
- long double
- wchar_t (C++ only)
- The following are ignored if they are present in the
header file.
- Storage class specifiers:
-
- auto
- register
- static
- extern
- mutable
- Qualifiers
-
- const
- volatile
- _Export (C++ only)
- Function specifiers
-
- inline (C++ only)
- virtual (C++ only)
- Initial values
- The header file must not contain these items:
- Unions
- Class declarations
- Enumeration data types
- Pointer type variables
- Template declarations
- Predefined macros; that is, macros with names that start and end with two underscore characters ( __ )
- The line continuation sequence (a \ symbol that is immediately followed by a newline character)
- Prototype function declarators
- Preprocessor directives
- Bit fields
- The __cdecl (or _cdecl) keyword (C++ only)
- The application programmer must use a 32-bit compiler to ensure that an int maps to 4 bytes.
- The following C++ reserved keywords are not supported:
- explicit
- using
- namespace
- typename
- typeid
- If the MAPPING-LEVEL parameter is set to 1.2 or higher and the CHAR-VARYING parameter is set to NULL, character arrays are mapped to an string and are processed as null-terminated strings.
- If the MAPPING-LEVEL parameter is set to 1.2 or higher and the CHAR-VARYING parameter is set to BINARY, character arrays are mapped to xsd:base64Binary and are processed as binary data.
- If the MAPPING-LEVEL parameter is set to 1.2 or higher and the CHAR-VARYING parameter is set to COLLAPSE, <xsd:whiteSpace value="collapse"/> is generated for strings.
| C and C++ data type | Schema simpleType |
|---|---|
| char[ z ] |
|
| char16_t[ n ] | At mapping level 4.0 and higher:
At run time, CICS® populates the application data structure field with UTF-16 data. |
| char[8]
Supported at mapping level 3.0 and higher when DATETIME=PACKED15 |
The format of the timestamp is defined
by
RFC3339.
|
| char |
where
n
is the maximum value that can
be represented by the primitive.
|
| unsigned char |
where
n
is the maximum value that can
be represented by the primitive.
|
(C++ only)
|
|
Supported at 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 float data types with fixed precision
alternatives.
|
Supported at 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 double data types. Some values may lose precision when
converted
to or from HFP representation. If precise conversions are
important,
consider replacing use of double data types with fixed precision
alternatives.
|
| type name [ n ] | For primitives:
For structs:
Where
type JSON
is the JSON schema
representation of the C or C++ type.
|