-
Notifications
You must be signed in to change notification settings - Fork 82
Compact Naming
Supported by Jsonix since version 2.1.0 and Jsonix Schema Compiler from version 2.2.0.
This feature is not backwards compatible - older Jsonix versions will not be able to read mappings with compact naming. However, newer version of Jsonix (2.1.0 and up) will stil read your "normal" (i.e. not compact) mappings. There are no plans to drop normal mappings.
Jsonix Schema Compiler 2.2.0 and up generate normal mappings by default but have a switch to generate compact mappings instead.
In order to reduce the size of mapping scripts, Jsonix offers compact naming. You can just replace long property names in mappings with their short versions.
Compact naming drastically reduces the size of the mapping files, you can expect 25-50% reduction in size.
The following sections list compact names corresponding to the full names as well as their default values.
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
name |
defaultElementNamespaceURI |
defaultAttributeNamespaceURI |
typeInfos |
elementInfos |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
defaultElementNamespaceURI |
defaultAttributeNamespaceURI |
elementName |
If it is a string, the qualified name will be formed using the defaultElementNamespaceURI
|
typeInfo |
substitutionHead |
scope |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
type |
classInfo |
enumInfo |
list |
localName |
name |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
| `baseTypeInfo |
| ` |
| ` |
separator |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
baseTypeInfo |
values |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
defaultElementNamespaceURI |
defaultAttributeNamespaceURI |
baseTypeInfo |
instanceFactory |
properties |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
name |
defaultElementNamespaceURI |
defaultAttributeNamespaceURI |
collection |
type |
Mapping properties above apply to all properties.
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
anyAttribute |
anyElement |
attribute |
elementMap |
element |
elements |
elementRef |
elementRefs |
value |
Any attribute property does not have any additional mapping parameters.
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
allowDom |
allowTypedObject |
mixed |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
attributeName |
typeInfo |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
elementName |
wrapperElementName |
key |
value |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
elementName |
wrapperElementName |
typeInfo |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
wrapperElementName |
elementTypeInfos |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
elementName |
typeInfo |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
elementName |
wrapperElementName |
| mixed |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
wrapperElementName |
mixed |
elementTypeInfos |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
elementName |
typeInfo |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
typeInfo |
|Name|Compact name|Default value|Description|
| ---- |
|---|
| ------------- |
| ----------- |
localPart |
namespaceURI |
prefix |
Since Jsonix version 2.1.0.
When referencing types within the same module, you can use the compact syntax .MyType instead of the full name MyModule.MyType.
Example:
Five = {
n : 'Five',
tis : [ {
ln : 'ValueType',
ps : [ {
t : 'v',
n : 'value'
} ]
}, {
ln : 'ElementsType',
ps : [ {
t : 'es',
n : 'ab',
etis : [ {
en : 'a',
// We can use .ValueType instead of Five.ValueType
ti : '.ValueType'
}, {
en : 'b',
ti : 'Integer'
} ]
} /*...*/ ],
} ],
eis : [ /* ... */ ]
};