This repository has been archived by the owner on Jan 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from fengmk2/issue23-support-spacetext
fixed #23 support xml space text using `options.space`
- Loading branch information
Showing
9 changed files
with
62 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"itemRecord":{"value":[{"longValue":"12345"},{"stringValue":{"number":"false","$t":"this is a string value"}},{"moneyValue":{"number":"true","currencyId":"USD","$t":"104.95"}},{"moneyValue":{"currencyId":"USD","$t":"104.95"}},{"longValue":"0","bool":{"id":"0","$t":"true"}},{"longValue":"0"},{"dateValue":"2012-02-16T17:03:33.000-07:00"},{"stringValue":"SmDZ8RlMIjDvlEW3KUibzj2Q"}]}} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
{ | ||
"parent": | ||
{ | ||
"child": { "child_property": "foo" }, | ||
"parent_property": "bar" | ||
} | ||
} | ||
{"parent":{"parent_property":"bar","child":{"child_property":"foo"}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"doc":{"Column":[{"Name":"shit","Value":{"type":"STRING","$t":" abc\nasdf\na "}},{"Name":"foo","Value":{"type":"STRING"}},{"Name":"foo2","Value":{"type":"STRING"}},{"Name":"bar","Value":{"type":"STRING","$t":" "}},{"PK":"true","Name":"uid","Value":{"type":"STRING","$t":"god"}}]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<doc> | ||
<Column> | ||
<Name>shit</Name> | ||
<Value type="STRING"> abc | ||
asdf | ||
a </Value> | ||
|
||
</Column> | ||
<Column><Name>foo</Name><Value type="STRING"></Value></Column> | ||
<Column><Name>foo2</Name><Value type="STRING" /></Column> | ||
<Column><Name>bar</Name><Value type="STRING"> </Value></Column> | ||
<Column PK="true"><Name>uid</Name><Value type="STRING">god</Value></Column> | ||
</doc> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var parser = require('../lib'); | ||
var assert = require('assert'); | ||
|
||
var xml = fs.readFileSync(__dirname + '/fixtures/spacetext.xml'); | ||
var json = parser.toJson(xml, {object: true, space: true}); | ||
console.log('xml => json: \n%j', json); | ||
|
||
console.log('---------------------\njson => xml: \n%j\n', | ||
parser.toXml(fs.readFileSync(__dirname + '/fixtures/spacetext.json'))); | ||
function eql(a, b) { | ||
for (var k in a) { | ||
assert.deepEqual(a[k], b[k], JSON.stringify(a) + ' should equal ' + JSON.stringify(b)); | ||
} | ||
} | ||
|
||
assert.deepEqual(json.doc.Column.length, 5, 'should have 5 Columns'); | ||
eql(json.doc.Column[0], {Name: 'shit', Value: {type: 'STRING', $t: ' abc\nasdf\na '}}); | ||
eql(json.doc.Column[1], {Name: 'foo', Value: {type: 'STRING'}}); | ||
eql(json.doc.Column[2], {Name: 'foo2', Value: {type: 'STRING'}}); | ||
eql(json.doc.Column[3], {Name: 'bar', Value: {type: 'STRING', $t: ' '}}); | ||
eql(json.doc.Column[4], {PK: 'true', Name: 'uid', Value: {type: 'STRING', $t: 'god'}}); | ||
|
||
console.log('xml2json options.space passed!'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters