C and C++ to JSON schema mapping
The DFHLS2JS utility program supports mappings between C and C++ data types and JSON schema definitions.
C and C++ names are converted to JSON names according to
the following rules:
- Characters that are not valid in JSON property names are replaced
with '
X'.For example,
monthly-totalbecomesmonthlyXtotal. - Duplicate names are made unique by the addition of one or more
numeric digits.
For example, two instances of
yearbecomeyearandyear1.
DFHLS2JS maps C and C++ data types to schema elements according
to the following table. C and C++ types that are not shown in the
table are not supported by DFHLS2JS. The
_Packed qualifier
is supported for structures. These restrictions apply:- Header files must contain a top level
structinstance. - You cannot declare a structure type that contains itself as a member.
- The following C and C++ data types are not supported:
decimallong doublewchar_t(C++ only)
- The following are ignored if they are present in the
header file.
- Storage class specifiers:
autoregisterstaticexternmutable
- Qualifiers
constvolatile_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
intmaps to 4 bytes. - The following C++ reserved keywords are not supported:
explicitusingnamespacetypenametypeid
- 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
stringand 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:base64Binaryand 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 |
The format of the timestamp is defined
by RFC3339. |
charshortintlonglong long |
where n is the maximum value that can
be represented by the primitive. |
unsigned charunsigned shortunsigned intunsigned longunsigned long long |
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. |