JSONX

JavaScript library providing XML to JSON two-way transformations

JSONX is a JavaScript library which allows simple transformation between XML and JSON.

Please check back again soon to find more information and some examples.

JSONX to XML

JSONX.build(Array|String)

XML to JSON

JSONX.parse(Node|Node[]|NodeList|String)

Stringify

JSONX.stringify(Node|Node[]|NodeList|String)

Grammar

The following ANTLR grammar represents the XML to JSON transformation;

ELEMENT
  : '[' ELEMENT_NAME (',' '{' ATTRIBUTE_LIST? '}')? (',' ELEMENT_LIST)? ']'
  | STRING
  ;
ELEMENT_NAME : STRING ;
ATTRIBUTE_LIST
  : ATTRIBUTE ',' ATTRIBUTE_LIST
  | ATTRIBUTE
  ;
ATTRIBUTE : ATTRIBUTE_NAME ':' ATTRIBUTE_VALUE ;
ATTRIBUTE_NAME : STRING ;
ATTRIBUTE_VALUE
  : STRING
  | NUMBER
  | BOOLEAN
  | NULL
  ;
ELEMENT_LIST
  : ELEMENT ',' ELEMENT_LIST
  | ELEMENT
  ;
BOOLEAN
  : 'true'
  | 'false'
  ;
NULL : 'null' ;
NUMBER : '0'..'9'+ ;
STRING : 'a'..'z'+ ;

Bugs

If you have any problems with this library or would like to see the changes currently in development browse our issues.

Questions?

Take a look at the documentation to get a better understanding of what the code is doing.

If that doesn't help, feel free to follow me on Twitter, @neocotic.