question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

empty json field name when xml node has attributes

See original GitHub issue

When i’m trying to read an xml like :

<toto>
    <tata>toto</tata>
    <foo bar="youhou">nodeValue</foo>
</toto>
new XmlMapper().readTree(xmlStream);

the result is :

{"tata":"toto","foo":{"bar":"youhou","":"nodeValue"}}

with jettison i have this result :

{"tata":"toto","foo":{"@bar":"youhou","$": "nodeValue"}}

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
heraucommented, Feb 18, 2015

xmlMapper.setXMLTextElementName("$"); isn’t applicable because this method has a protected scope. But i can handle it with xmlMapper.getFactory().setXMLTextElementName("$");

0reactions
cowtowncodercommented, Feb 18, 2015

Ah yes. Protected access due to JacksonXmlModule being the intended mechanism, avoiding adding setters in mapper itself. Although if you really want to, can sub-class XmlMapper, open up access.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't parse empty xml property with attribute - Stack Overflow
It works perfectly with com.fasterxml.jackson of version 2.7.4 . But it fails with various errors if some of libraries has another version ...
Read more >
Handling JSON null and empty arrays and objects - IBM
Empty property ​​ The JSON empty concept applies for arrays and objects as shown below. In the case of address, an empty address...
Read more >
Limitations for JSON to XML Conversion - SAP Help Portal
The XML element and attribute names must not contain any delimiter characters, because the delimiter is used in JSON to separate the prefix...
Read more >
XML Schema Complex Type - Empty Elements - W3Schools
XSD Empty Elements​​ An empty complex element cannot have contents, only attributes.
Read more >
Controlling XML Serialization Using Attributes - Microsoft Learn
By default, an XML element name is determined by the class or member name. In a class named Book , a field named...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found