Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit 115e66f

Browse files
committed
wip readme
1 parent 8a92e8b commit 115e66f

1 file changed

Lines changed: 32 additions & 5 deletions

File tree

README.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff 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+
```
1618
var parser = require('xml2json');
1719
1820
var 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
2022
console.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+
| `<` | `&lt;` |
34+
| `>` | `&gt;` |
35+
| `(` | `&#40;`|
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

3158
Permission is hereby granted, free of charge, to any person obtaining a copy
3259
of this software and associated documentation files (the "Software"), to

0 commit comments

Comments
 (0)