-
Notifications
You must be signed in to change notification settings - Fork 606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'preserveChildrenOrder' option not working #202
Comments
You can just use the git version in the meantime and let me know if it works, which would help me to make sure I'm realeasing a 0.4.9 that actually works properly. |
Hi there, Unfortunately it does not work with the current git version for my use case. Here's an example where you can reproduce the behavior.
The corresponding "tmp.xml" file is like
When I now set both, "explicitChildren" AND "preserveChildrenOrder" to true, it fails with this error message:
Thanks in advance. |
I'm working on a fix for this. Would like to hear your opinions. I think the only reliable solution for this is to introduce an explicit index when converting xml to js(on) (at least when you use explicitChildren=false). The index will be removed when json is converted back to xml, but it will dictate the order of the xml tags. In my project this would look like this:
the json looks something like this (actually skipped some details to improve readability):
Without my patch, the only way to produce this JSON would be to have an actual |
@ds82 Thank you +1 Just used your fork to process some SVG that was breaking without your patches. |
any fix for this? #index prop would be very useful for me! |
Still waiting for a fix :( |
I switched to https://github.com/nashwaan/xml-js that worked for my requirements. It preserves the order. Also if your input xml is deeply nested, you might find the https://marketplace.visualstudio.com/items?itemName=nidu.copy-json-path plugin useful (I guess similar plugins are available for other IDE's as well). You can easily navigate the output JSON using this plugin. This saved a lot of time for me. |
The input xml is as shown
<data>
<a>A</a>
<a>A</a>
<b>B</b>
<b>B</b>
<c>C</c>
<c>C</c>
<a>A</a>
<b>B</b>
<c>C</c>
</data>
and the output is
{ data:
{ a: [ 'A', 'A', 'A' ],
b: [ 'B', 'B', 'B' ],
c: [ 'C', 'C', 'C' ] } }
I saw that it will be available from 0.4.9 version. But the latest version available is 0.4.8. But I downloaded the code and tried the above input.
This feature is very important for me. Please let me know when this will be released
Thanks In Advance
The text was updated successfully, but these errors were encountered: