add `attributes` and `textNodeName` options to xml parser #15

Closed
wants to merge 2 commits into
from

Projects

None yet

1 participant

@huned

I added a couple options (and tests) for xml2json.js that I needed and that others may find useful:

  • a textNodeKey option to override the default $t -- because I need to generate JSON that I can feed into mongodb. mongodb does not like '$' in JSON key names. When not specified, the textNodeKey option defaults to '$t'

  • an attributes option to specify whether or not the xml's nodes' attributes are converted to the JSON. The default is attributes: true which preserves the usual behavior of allowing attributes into the generated JSON.

huned added some commits Feb 1, 2012
@huned huned options.textNodeKey specifies the json key for a node's text data. if…
… unspecified, defaults to usual $t.
1d0aff2
@huned huned options.attributes specifies whether or not xml nodes' attributes are…
… generated in the json. if unspecified, defaults to , preserving the usual behavior of generating json that includes the node's attributes
07944ad
@huned

2 years old -- surely stale by now.

@huned huned closed this Mar 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment