Skip to content
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

Implement a way of parsing xml to closely resemble that of xml. #160

Conversation

jinq102030
Copy link
Contributor

Purpose / Goal

Be able to parse each xml node in the form of { nodeName, attr, val, namespace, children}.
This makes it easier to process JSON from xml because there is not need to constantly check if a child node is an array or non-array.

This feature only applies when you enable resembleXml option (default is false).

Each xml node will be parsed to { nodeName, attr, val, namespace, children}
@coveralls
Copy link

Coverage Status

Coverage decreased (-7.6%) to 89.633% when pulling 4c9e50f on jinq102030:reassemble_xml_when_parsing_xml_to_json into 65c39be on NaturalIntelligence:master.

@coveralls
Copy link

coveralls commented Apr 30, 2019

Coverage Status

Coverage decreased (-0.7%) to 96.491% when pulling 241bac0 on jinq102030:reassemble_xml_when_parsing_xml_to_json into 65c39be on NaturalIntelligence:master.

@amitguptagwl
Copy link
Member

Thanks for the PR. Can you plz add necessary tests? So I can understand your thoughts better.

@amitguptagwl
Copy link
Member

Thanks for adding the tests to cover few scenarios. We received a feature request for some part of this implementation few days back, and we ended with the discussion that a separate schema builder should be written.

So, here, we want to understand the need and need to discuss the output structure before merging the changes. Where did you get this idea from? your personal project/need or you found the same solution somewhere else in other parsers etc.

@jinq102030
Copy link
Contributor Author

Glad someone else also has such a request. In our development, we felt that it's very cumbersome to have to deal with aggregation:
A xml node has 5 children, 3 of them has the same nodeName (A) and aggregated, the other two have unique nodeNames (B, C). So the object for A is an array of 3 element, the objects for B or C are not array.

Our code has to do lots of check to see if the object for a given nodeName is an array or not, it created so much if else conditions and it's becomes hard to manage.

@amitguptagwl
Copy link
Member

So the main issue I see here is to have the elements in array. I'll suggest you go through following issues and PR;

#68
#135

@amitguptagwl amitguptagwl self-requested a review May 6, 2019 09:54
@jinq102030
Copy link
Contributor Author

Thanks for the suggestion, will check it out. Sorry for the late reply.

@amitguptagwl
Copy link
Member

As we have published arrayMode now. I'm closing this PR. Thanks for your effort.

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

Successfully merging this pull request may close these issues.

3 participants