Jsonix Attribute Property

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: 'InputType',
        propertyInfos: [{
            type: 'attribute',
            typeInfo: 'Boolean',
            name: 'checked'
        }]
    }],
    elementInfos: [{
        elementName: 'input',
        typeInfo: 'MyModule.InputType'
    }]
};
var context = new Jsonix.Context([MyModule]);
var unmarshaller = context.createUnmarshaller();
var unmarshalled = unmarshaller.unmarshalString('<input checked="false"/>');
console.log(unmarshalled);

var marshaller = context.createMarshaller();
var marshalled = marshaller.marshalString({
    name: {
        localPart: 'input'
    },
    value: {
        checked: false
    }
});
console.log(marshalled);