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

Parsing array data with a namespace strips whitespace #35

Open
ssinger opened this issue Dec 21, 2015 · 1 comment
Open

Parsing array data with a namespace strips whitespace #35

ssinger opened this issue Dec 21, 2015 · 1 comment

Comments

@ssinger
Copy link

ssinger commented Dec 21, 2015

The following test case fails,

The difference between this test and testXmlWithSpaceArray which works is the xmlns attribute on the 'e' element.

 public void testXmlWithSpaceArrayNamespace() throws IOException, SAXException,     ParserConfigurationException {
        String xml =
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<e xmlns=\"urn:foo-1.0\">\n" +
               "   <c>\n" +
                "      <u>\n" +
                "            <chg>\n" +
                "                  <a>\n" +
                "                      <s>   </s>" +
                "                      <s>   </s>" +
                "                  </a>" +
                "            </chg>\n" +
                "      </u>\n" +
                "   </c>\n" +
                "</e>";

        final XMLSerializer tested = new XMLSerializer();
        //tested.setKeepCData(true);
        tested.setTypeHintsEnabled(false);        
        tested.setRootName("data");

         final JSON jsonRepresentation = tested.read(xml);
        final String jsonText = jsonRepresentation.toString();
        assertTrue(jsonText.contains("[\"   \""));
    }
@aalmiray
Copy link
Collaborator

Generated JSON without the namespace:

{"command":{"update":{"chg":{"addr":["   ","   "]}}}}

Generated JSON with the namespace:

{"@xmlns":"urn:foo-1.0","command":{"update":{"chg":{"addr":{"street":[{},{}]}}}}}

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

No branches or pull requests

2 participants