- With Jsonix you can parse XML into JSON (this process is called unmarshalling) or serialize JSON in XML form (this is called marshalling).
- These conversions are based on declarative XML/JSON mappings which can be written manually or generated from an XML Schema.
- Strongly structured
- (Optionally) XML Schema-driven
See also the other Jsonix features.
Here's a working example for the purchase order schema (try it online in JSFiddle).
java -jar node_modules/jsonix/lib/jsonix-schema-compiler-full.jar -d mappings -p PO purchaseorder.xsd
Generates mappings for the
purchaseorder.xsd schema in the
mappings\PO.js; mappings will be placed in the variable
Parse XML into JS
// Include or require PO.js so that PO variable is available// For instance, in node.js:var PO = PO;// First we construct a Jsonix context - a factory for unmarshaller (parser)// and marshaller (serializer)var context = PO;// Then we create a unmarshallervar unmarshaller = context;// Unmarshal an object from the XML retrieved from the URLunmarshaller;
You can also
unmarshalDocument and (under node.js)
Serialize JS as XML
You can also
- Runs in almost any modern browser
- Runs in Node.js,
package.jsoncan be found here
- Runs with CommonJS modules, AMD modules as well as vanilla (globals, without any module loader)
- Bidirectional (XML -> JS as well as JS -> XML)
- Supports string data and DOM nodes as result
- Supports string data, DOM nodes, URLs or files (with Node.js) as source
- Mappings can be automatically generated based on the XML Schema
- Provides extensible type system
- Supports most XML Schema simple types (inlcuding QNames)
- Supports enumerations, list and union simple types
- Allows adding own simple types
- Supports complex types consisting of several properties
- Supports deriving complex types by extension
- Provides advanced property system
- Value, attribute, element, element reference properties for string processing of XML content
- Any attribute, any element properties for "lax" processing for XML content
Many thanks to JetBrains for providing a free open-source license for Jsonix development.