I successfully got an schema object created by jsonix. Now I want to convert json strings to xml. This is my code:
var Jsonix= require('jsonix');
var context= new Jsonix.Context([myschemaobj]);
here I get the error that Jsonix.Context is not a function. What ist wrong with my code?
Jsonix node.js module exports an object named `Jsonix``. So you have to require Jsonix and your mappings as follows:
var Jsonix = require('jsonix').Jsonix;
var PO = require('./PO/Mappings').PO;
And then:
var context = new Jsonix.Context([ PO ]);
var unmarshaller = context.createUnmarshaller();
var result = unmarshaller.unmarshalString('<comment>test</comment>');
test.equal('comment', result.name.localPart);
test.equal('test', result.value);
Disclaimer: I'm the author of Jsonix.