Jsonix Complex Types
by Alexey Valikov
HTML
<script src="https://rawgithub.com/highsource/jsonix/master/dist/Jsonix-all.js"></script>
JavaScript
var MyModule = {
name: 'MyModule',
typeInfos: [{
type: 'classInfo',
localName: 'DataType',
propertyInfos: [{
type: 'value',
name: 'value',
typeInfo: 'Integer'
}, {
type: 'attribute',
name: 'key',
attributeName: 'key',
typeInfo: 'String'
}]
}],
elementInfos: [{
elementName: 'data',
typeInfo: 'MyModule.DataType'
}]
};
var context = new Jsonix.Context([MyModule]);
var unmarshaller = context.createUnmarshaller();
var unmarshalledData = unmarshaller.unmarshalString('<data key="one">1</data>');
console.log(unmarshalledData);
var marshaller = context.createMarshaller();
var marshalledData = marshaller.marshalString({
name: {
localPart: 'data'
},
value: {
key: 'one',
value: 1
}
});
console.log(marshalledData);