XML Empty tag to Empty string in the object during xml deserialization
See original GitHub issueI am using jackson-dataformat-xml:2.6.2
If an empty tag is available in the xml and the respective field in the object is a string, it would be nice to have jackson populate the field with empty string rather than with null value.
Ex:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(
name = "",
propOrder = {"first", "last"}
)
@XmlRootElement(
name = "name"
)
public class Name {
private String first;
private String last;
}
xml:
<name>
<first>Ryan</first>
<last></last>
</name>
mapper creation:
new XmlMapper(XMLInputFactory2.newFactory(), XMLOutputFactory2.newFactory());
I would expect
Name name = mapper.readValue(xml, Name.class)
name.getLast().equals(“”) to return true but name.getLast() ends up being null.
Any help would be appreciated.
Issue Analytics
- State:
- Created 8 years ago
- Comments:18 (8 by maintainers)
Top Results From Across the Web
c# - Deserialize Xml with empty elements - Stack Overflow
I used this approach. First it removes the null or empty elements from the XML file using LINQ and then it deserialize the...
Read more >differentiating between null and empty string in a xml ... - MSDN
Hi guys,. I have a xml which i Deserialize, using XMLSerializer class, into a custom object. One property of the custom object is...
Read more >[Solved] Deserializing empty XML tags in C# with enumerations
I've been playing with the XmlIgnore attribute and created another member to import the value for the empty tag as a String, and...
Read more >[Solved]-Xml Serialization - Render Empty Element-C#
The solution to this was to create a PropertyNameSpecified property that the serializer uses to determine whether to serialize the property or not....
Read more >Jackson XML ignore empty element
Deserialization from XML. Jackson also allows us to read the contents of an XML file and deserialize the XML String back into a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any idea when the PR might be merged if approved?
Is there any fix for this which is available?