You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
For versatility, it would be great to have an option of not adding <data></data> by default.
Maybe it should be an option, where if "" is specified, no <data></data> is created, if "root" is specified, <root></root> will be created.
Good point, I really like the idea of making the root name configurable as in your <root></root> example. That would be simple to implement.
Allowing for no root element at all would be less clean to implement, mainly because that isn't valid XML. Could you let us know the use case for this? If it's important to have we can certainly give it some thought. Thanks for the idea!
Allowing for no root element at all would be less clean to implement, mainly because that isn't valid XML. Could you let us know the use case for this?
My use case is pretty simple:
I have an XML document that has one root element:
<entry>
...
</entry>
I convert this document to JSON using node-xmljson.
Then I convert this JSON back to XML. I get this result:
<data>
<entry>
...
</entry>
</data>
If root element could be configurable, I could convert entries inside of entry JSON object to XML with specifying root element as "entry". But this workaround is less than optimal.
Got it, <entry> ... </entry> should probably translate to { ... } the same way <data> ... </data> does. Then, going from JSON to XML { ... } should be able to translate back to <entry> ... </entry> if we allow specifying a name for the root element (as you suggest). Does that cover it or is this approach what you feel is less than optimal? If so, what do you think would be more optimal?
Hello,
I'm running into the same issue and I think that sounds like a good solution. However, would it make it easier to use the first property as the root node when converting to xml? I think either solution would work.
For versatility, it would be great to have an option of not adding
<data></data>by default.Maybe it should be an option, where if "" is specified, no
<data></data>is created, if "root" is specified,<root></root>will be created.