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

position of $t property is matter for XML generation #147

Open
iuriifavi opened this issue Oct 3, 2017 · 2 comments
Open

position of $t property is matter for XML generation #147

iuriifavi opened this issue Oct 3, 2017 · 2 comments

Comments

@iuriifavi
Copy link

xml2json.toXml({ShippingServiceAdditionalCost: { '$t': 0, currencyID: 'USD' } }})
==
"<ShippingServiceAdditionalCost>0 currencyID="USD"</ShippingServiceAdditionalCost>"

and

xml2json.toXml({ShippingServiceAdditionalCost: { currencyID: 'USD', '$t': 0 } }})
==
"<ShippingServiceAdditionalCost currencyID="USD">0</ShippingServiceAdditionalCost>"
@c4milo
Copy link
Contributor

c4milo commented Oct 3, 2017

hmm, interesting. It looks like a bug indeed.

@iuriifavi
Copy link
Author

ToXml.prototype.parse = function(obj) {
var self = this;
var keys = Object.keys(obj);
var len = keys.length;

// Sub node should be moved to the end
keys.sort(_ => _ == '$t');

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants