This repository was archived by the owner on Jan 7, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,25 +8,52 @@ It does not parse the following elements:
88* Entity declarations
99* Comments
1010
11- ## Installation
12- ` npm install xml2json `
11+ ## Installation
12+ ```
13+ $ npm install xml2json
14+ ```
1315
1416## Usage
15- ``` javascript
17+ ```
1618var parser = require('xml2json');
1719
1820var xml = "<foo>bar</foo>";
19- var json = parser .toJson (xml); // returns an string containing the json structure by default
21+ var json = parser.toJson(xml); //returns a string containing the JSON structure by default
2022console.log(json);
2123```
24+ ### Options
25+
26+ * ** object:** Returns a Javascript object instead of a JSON string
27+ * ** reversible:** Makes the JSON reversible to XML (* )
28+ * ** coerce:** Makes type coercion
29+ * ** sanitize:** Sanitizes the following characters:
30+
31+ | Character | Escaped |
32+ | --------- | ------- |
33+ | ` < ` | ` < ` |
34+ | ` > ` | ` > ` |
35+ | ` ( ` | ` ( ` |
36+ | | |
37+ | | |
38+
39+ * ** trim:**
40+
41+ ```
42+ options = {
43+ object: false,
44+ reversible: false,
45+ coerce: true,
46+ sanitize: true,
47+ trim: true };
48+ ```
2249* if you want to get the Javascript object then you might want to invoke parser.toJson(xml, {object: true});
2350* if you want a reversible json to xml then you should use parser.toJson(xml, {reversible: true});
2451* if you want to keep xml space text then you should use ` options.space ` , ` parser.toJson(xml, {space: true}) ` ;
2552
2653## License
2754(The MIT License)
2855
29- Copyright 2011 BugLabs. All rights reserved.
56+ Copyright 2012 BugLabs. All rights reserved.
3057
3158Permission is hereby granted, free of charge, to any person obtaining a copy
3259of this software and associated documentation files (the "Software"), to
You can’t perform that action at this time.
0 commit comments