null-handling ignored
See original GitHub issueWith 2.12.1-SNAPSHOT the following code:
XML_MAPPER = new XmlMapper();
XML_MAPPER.configOverride(List.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY));
XML_MAPPER.configOverride(Set.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY));
XML_MAPPER.configOverride(Map.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY));
XML_MAPPER.enable(FromXmlParser.Feature.EMPTY_ELEMENT_AS_NULL);
List<LoggerTO> original = new ArrayList<>();
StringWriter writer = new StringWriter();
XML_MAPPER.writeValue(writer, original);
List<LoggerTO> actual = XML_MAPPER.readValue(writer.toString(), new TypeReference<List<LoggerTO>>() {
});
assertEquals(original, actual);
fails with message
org.opentest4j.AssertionFailedError: expected: <[]> but was: <null>
I have verified that serialization produces
<ArrayList/>
Issue Analytics
- State:
- Created 3 years ago
- Comments:22 (12 by maintainers)
Top Results From Across the Web
NullValueHandling setting - Json.NET
This sample serializes an object to JSON with NullValueHandling set to Ignore so that properties with a default value aren't included in the...
Read more >How to ignore a property in class if null, using json.net
Include to :=NullValueHandling.Ignore. By the way - I've found that you can decorate a property for both XML and JSON serialization just fine...
Read more >ExampleMatcher.NullHandler (Spring Data Core 3.0.0 API)
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum...
Read more >JSON serialization: Ignore selective properties or null properties
This article is to explain how to ignore null values or some properties from being ... NullValueHandling = NullValueHandling.Ignore
Read more >NULL Semantics - Spark 3.0.0-preview Documentation
Null handling in null-in-tolerant expressions; Null handling Expressions that ... NULL values are ignored from processing by all the aggregate functions.
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
For what it is worth, empty element like
<ArrayList></ArrayList>
(or<ArrayList />
) should be deserialized as emptyList
with 2.12, as long as you do NOT enableFromXmlParser.Feature.EMPTY_ELEMENT_AS_NULL
. This was not the case with 2.11, regardless of setting as handling of empty elements had problems – mostly because at low level such elements would be equivalent to JSON empty String value. Support for this case was improved injackson-databind
2.12, to let XML module work better for this relatively common case.I hope it is now possible to get things to work in a usable way: unfortunately the full combination of various aspects is not easy to reason about and it can be frustrating to find a good combination. Especially when attempting to make things work the same way against different versions.
I am planning to release
2.12.1
very soon now, for what that is worth; there are a few important fixes.FYI with these settings all is passing now, both with 2.11 and 2.12.1-SNAPSHOT: https://github.com/ilgrosso/jackson-dataformat-xml-437/blob/main/src/test/java/net/tirasa/test/XMLTest.java#L23-L39