-
Notifications
You must be signed in to change notification settings - Fork 78
Basic Concepts
Alexey Valikov edited this page Nov 6, 2015
·
1 revision
Jsonix mappings are defined in a module object which provides information about declared types and XML elements which they are mapped to. Below is a very simple module One
which declares a complex type One.ValueType
(containing a single property value
) and maps this type to the global XML element value
:
var One = {
name: 'One',
typeInfos: [{
type: 'classInfo',
localName: 'ValueType',
propertyInfos: [{
name: 'data',
type: 'value',
typeInfo: 'String'
}]
}],
elementInfos: [{
elementName: 'value',
typeInfo: 'One.ValueType'
}]
};
Provided this module object, we can create a Jsonix context and use it for marshalling or unmarshalling:
var context = new Jsonix.Context([One]);
var unmarshaller = context.createUnmarshaller();
var data = unmarshaller.unmarshalString('<value>Some text.</value>');
console.log(data);
See the Fiddle for this example.
Now we can enumerate basic components of Jsonix mappings:
These components will be described in the following sections.