jQuery plugin for JSONX
jQuery JSONX is a jQuery plugin which allows simple transformation between XML and JSON.
This is a jQuery implementation for the JSONX JavaScript library which provides the same transformation support as well as additional manipulation and management using the powerful jQuery framework.
Once I have fully documented the code I will make another release of the plugin and publish it on the jQuery plugins directory. I hope to get this done soon but in the meantime you can hopefully get a good understanding of how to use it by looking at the code.
Please check back again soon to find more information and some examples.
$(*).jsonx(Array|String)
$.jsonx(Array|String)
$(*).jsonx('build', Array|String)
$.jsonx('build', Array|String)
$(*).jsonx('parse'[, jQuery|String])
$.jsonx('parse'[, jQuery|String])
The current jQuery context will be parsed if
the second argument is omitted for parse
.
$(*).jsonx('stringify'[, Array|jQuery])
$.jsonx('stringify'[, Array|jQuery])
The current jQuery context will be transformed
into a string if the second argument is omitted for stringify
.
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'+ ;
If you have any problems with this plugin or would like to see the changes currently in development browse our issues.
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.