-
Notifications
You must be signed in to change notification settings - Fork 38
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
Use xml2js for xmlToJson() #53
Conversation
I'm not sure changing Xml2Json format and how it's used (async) is such a good idea. That's a breaking change and will affect all users. Perhaps instead, we leave Xml2Json as-is and allow users to opt-in to xml2js somehow, instead? Or do we not necessarily care about compatibility before 1.0? |
Agree. It is better to keep the old The old xmlToJson API breaks the structure of the original xml output, especially for the |
Now the code changes pass all test cases. As a fix for issue #11 , previously the BLANK item has a value of '', now it is undefined. |
bfb6c74
to
5c32751
Compare
I think the best thing to do for compatibility is to have an option to use XmlToJson instead of using xml2js, just like we have for returning an error. The deprecated constructors would use XmlToJson always, but the object constructor could have an option to use XmlToJson if desired (off by default and deprecated). Then at V2 we can remove XmlToJson. |
The basic functions like CommandCall, ProgramCall, SqlCall ( or the old iCmd, iPgm, iSh, iSql... ) require calling xmlToJson/xmlToJs explicitly and the usages are very different, I do not think an option is needed to distinguish them.
As for the toolkit APIs (lib/Toolkit.js), we can check a new option in the @kadler, So the option only affects the toolkit APIs, right? |
Signed-off-by: Xu Meng <mengxumx@cn.ibm.com>
Signed-off-by: Xu Meng <mengxumx@cn.ibm.com>
Ok, so it seems that the only usages of xmlToJson within the code is usage by tests and internal implementation defails of the high level wrappers (eg. sendToDataQueue). From that point of view, we don't have any compatibility issues to deal with. I would suggest then not exporting any xmlToJs API or similar. Let users import and use xml2js themselves (and recommend it to users). We can internally use it in place of xmlToJson, but I don't see much use for wrapping it in our own xmlToJs API. |
The v1.0-dev branch is no more. Please re-open to master. |
To resolve issue #9 & #47 , open this draft PR for tracking code changes.
Since
xml2js
provides an async interface, the usage of xmlToJson() has to be updated.The output JSON structure has been changed as well -->
Old JSON:
New JSON: