326 questions
1
vote
1
answer
191
views
How do I prevent a Maven mojo parameter from being encoded on write to XML?
I'm writing a custom Maven plugin for building a Flatpak from a Java project. In a Maven mojo I understand we use @Parameter annotations to parse pom.xml file configurations. For example:
pom.xml:
<...
0
votes
1
answer
106
views
Deserialize XML with Jackson polymorphically also using an external element
I need to deserialize XML into polymorphic Java classes where the subtype is determined not just by a type attribute on <component>, but also by a sibling <version> element. For example, &...
0
votes
0
answers
59
views
XML response not rendered currently in Spring Boot Rest API Using jackson dataformat xml
My model classes and serializer classes are like below and my problem is XML output is not rendered correctly.
EmployeesRoot.java:
@JacksonXmlRootElement(localName = "employees", namespace = ...
2
votes
1
answer
81
views
Missing segments when reading XML file
I am working on a demo application to read an XML file. When reading the XML file I am noticing a few XML segments are missing on the java object.
Here is a sample XML I am using:
<person xid="...
0
votes
0
answers
40
views
Proguard Rules for jackson-dataformat-xml
I am implementing Jackson with this dependencies
implementation ('com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.18.2')
implementation 'javax.xml.stream:stax-api:1.0-2'
https://...
0
votes
0
answers
95
views
Unable to perform Jackson deserialisation for boolean and int
My XML
<Parent>
<childs>
<child>1</child>
<child>0</child>
</childs>
</Parent>
Pojo Structure is
class Parent
{
@...
1
vote
1
answer
141
views
JacksonXmlRootElement root element name ignored while deserializing
I'm trying to deserialize an XML file into a Java object but, apparently, Jackson ignores the root element name.
I tried adding the @JacksonXmlRootElement annotation, following suggestions from these ...
0
votes
1
answer
80
views
How to parse this rare XML structure with Retrofit?
I'm using Retrofit and Jackson with XML parser to transform this XML into data classes. As you can see it's a very rare array inside child_group... there is one item and one info, one item and one ...
1
vote
1
answer
87
views
Jackson Xml parsing chooses attribute instead of tag
I have this xml file:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<nms:nmsDocument xmlns:nms="http://www.nms.com/xml" xmlns:xsi="...
1
vote
0
answers
29
views
How to enable CData Globally?
Enable CDATA for all string fields in jackson-dataformat-xml
I am aware that we can do it individually by adding @JacksonXmlCData for variable. But want to set it globally while serializing.
Currently ...
1
vote
2
answers
75
views
Jackson XML reading mixed sibling nodes
Jackson seems to be overwriting the older sibling nodes if the order is mixed. See below test case. Is this a bug or is there a way to make this work? Thanks.
@JacksonXmlRootElement
data class ...
1
vote
0
answers
71
views
How to parse XML lists with Jackson without a special case for 1 element lists?
I would like to use Jackson JsonNode to parse XML files that have this type of structures very often:
<list>
<element>
<a>value 1a</a>
<b&...
0
votes
1
answer
74
views
XML lists containing children with same name produce Jackson InvalidDefinitionException
I have a problem with an XML DTO. I was trying to assemble it in Spring Boot 3.3.5 and jackson-dataformat-xml v2.18.2. The issue here is that I have two lists that contain children with the same name ...
0
votes
1
answer
43
views
Is it possible to have multiple wrappers without creating extra classes using fasterxml?
I have to consume xml documents that have multiple nesting levels with each level containing only one single property.
<xml>
<level1>
<level2>
<level3>
...
0
votes
1
answer
365
views
Jackson XmlMapper doesn't handle xml attribute correctly while deserialization
I'm trying to read xml from text, modify it, and print it. Creating an object from text to class is unavailable, since I have a class that extends Slf4jEventSender, and I'm trying to override ...
3
votes
1
answer
86
views
Jackson XML ArrayList serialization
I have problem with serialization.
I have XML :
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped"/>
<ds:Transform Algorithm="...
1
vote
1
answer
113
views
Mapping Json during deserialization with different casing
I am facing an issue with mapping of JSON to my class.
When I hit the /greeting2 API from Postman, I get {} as response, but when I add @JsonProperty to the field along with @XmlElement, I get the ...
0
votes
0
answers
46
views
How to manage \uFFFF character with Jackson (XML)? [duplicate]
I've just come across what I believe is a weird behaviour in Jackson XML (de)serialization.
The character \uFFFF is accepted when serializing but leads to an error when deserialized.
XmlMapper xml = ...
1
vote
1
answer
577
views
How to force XmlMapper to retain the root element?
I have the following minimal code:
final var xmlString = "<parent><child>data</child></parent>";
final var xmlMapper = XmlMapper.xmlBuilder()
.enable(...
-1
votes
1
answer
71
views
XmlMapper cannot read an XML content
I am trying to read XML content but it gives me the following error:
Unrecognized field "Blob" (class com.example.blobstorage.dto.Blobs), not marked as ignorable (one known property: "...
-1
votes
1
answer
53
views
Java - Jackson XML serializing with dynamic child
I need to generate 2 xml files which are practically identical except for the name of the first element after the root element
Add.xml
<root>
<addPerson>
<person idPerson=&...
1
vote
0
answers
142
views
Jackson XML can't deserialize XmlElements correctly from Jakarta
I am trying to use Jackson XML for my jakarta deserialization but for xmlElements it does not seem to work and results in a null object. All other normal fields with just XmlElement do deserialize ...
1
vote
0
answers
29
views
Deserialize and process only certain fields, but retain the rest
A component in a messaging system should only work on certain properties of each message and be indifferent about the other ones. Messages are being passed in the XML format. Using the Jackson library,...
1
vote
1
answer
206
views
Usin ToXmlGenerator to serialize a XML file
I need to serialize an XML, the input I want is something like:
<item id="123">description</item>
I have a serializer that has the following code:
toXmlGenerator....
0
votes
0
answers
82
views
Jackson- reading '&' into unicode \u0026
I am using the jackson-dataformat-xml to read some xml.
In some of the Strings its reading the xml special character & as: &
When jackson reads it into a POJO the character is turned into: ...
-1
votes
1
answer
107
views
Converting xml string to 'this' class using jackson
I am using Jackson to work with my XML data, based on this Baeldung tutorial.
I have the following class to model some XML:
import com.fasterxml.jackson.core.JsonProcessingException;
import com....
1
vote
1
answer
274
views
How to use Jackson to deserialse an XML element with both value and attribute
I have been struggling to find a way to use Jackson to de-serialise this XML into Java:
<bitstream encoding="base64Binary">ew0KIklucH...bkpBTVMgQUEiDQp9</bitstream>
I have ...
0
votes
0
answers
48
views
How to configure Jackson2 XmlMapper to automatically detect repeated XML children nodes and replace them with a named array
I am using the following code:
ObjectMapper xmlMapper = new XmlMapper();
JsonNode jsonNode = xmlMapper.readTree("<fakeRoot>" + xmlText + "</fakeRoot>&...
0
votes
2
answers
216
views
How to express XML with mixed content using Jackson XmlMapper
I need write a Java program that will generate a XML with mixed content. It should more or less like this:
<foo>
<bar><a></a>Some text<b></b></bar>
...
1
vote
0
answers
644
views
Not able to parse joda DateTime fields into XML in springboot
I am having a org.joda.time.DateTime field in my API response object. The application gives proper response as json but when the Accept header is set to application/xml it fails with error
Caused by:...
0
votes
1
answer
65
views
How to map a nested XML element content as a string of a map?
I'm using Java and Jackson:
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2....
0
votes
0
answers
48
views
Getting the XML response from DispatcherServlet which is just cut off and no error is logged
I have a project with Spring (config is below):
<import resource="classpath:payment-impl-context.xml"/>
<import resource="classpath:abs-payment-consumer-context.xml"/>
...
0
votes
0
answers
230
views
Best way to xml to object using Kotlin fasterxml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dataset id="infoList">
<rows>
<row>
<lvl>4&...
0
votes
1
answer
46
views
With JacksonXML I'd like to deserialize unpredetermined list of elements to the Map<String,String>. What kind of annotations I can use for that?
I have xml tag with attribute names which are not restricted to some specific values,like that:
<to amount="345.00" service="service" purpose="rent" account="381&...
0
votes
1
answer
494
views
Java - Jackson XML Deserializing with generics
I'm trying to deserialize some XML using generics and I get an unexpected result.
Here is a simplified example of the code I'm using:
Maven dependecy
<dependency>
<groupId>com....
2
votes
2
answers
604
views
Java - Jackson XML Deserializing by Interface/Abstract class
I have these 2 XML's that I'm trying to deserialize with jackson-dataformat-xml:
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-...
1
vote
0
answers
70
views
Automatically resolve which implementation to use when deserializing using objectMapper
I am using objectMapper to deserialize xml to my object.
My xml has a section that has several possible fields, so I modeled my object using a sealed interface:
public record Root(String id, Child ...
0
votes
1
answer
628
views
Spring Boot Jackson XML Deserialization Ignore Property
During XML deserialization I want to ignore property @XmlSchemaType without modifying annotated class.
DO We have any such ignore control through application.property in spring boot?
0
votes
1
answer
433
views
I can't deserialize a wrapped List with Jackson XmlMapper
I'm trying to deserialize an XML list returned from a SOAP request, but I'm getting the following error:
com.fasterxml.jackson.databind.JsonMappingException: Duplicate property 'LstMyClassInfo' for [...
1
vote
1
answer
97
views
Jackson XML parsing, two wrappers have the same child element
My XML is a workflow exported from Jira. It looks like this:
<workflow>
<initial-actions>
<action>...</action>
<action>...</action>
</...
0
votes
1
answer
354
views
JacksonXML - Deserialize XML Comments <!-- -->
The closest question I can find currently is this which has no conclusive answer:
I am trying to parse XML comments and map it to certain fields in Java.
Below was a simple POC I did in attempt to get ...
0
votes
1
answer
72
views
How deserialize nesting with various depthion with Jackson?
I have xml with recursive nesting:
<root>
<groups>
<group>
<group_data>...group data...</group_data>
<object>...object data...</object>
...
1
vote
2
answers
921
views
Set namespace prefix in jackson POJO
In a Spring Boot 2.7.7 application using jackson-databind, jackson-dataformat-xml and jackson-datatype-jsr310 I want to generate this XML with namespaces and, more important, the prefix n1 (must be ...
0
votes
1
answer
411
views
deserializing XML list with jackson
I have some xml that looks as follows:
<model>
<action>
<items>
<input name="i1"/>
<input name="i2"/>
<output name=&...
1
vote
1
answer
1k
views
Jackson XML to JSON, ignore attributes
I have XML like this:
....
<dateIssuedField class="org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl" resolves-to="org.apache.xerces.jaxp.datatype....
0
votes
1
answer
223
views
Annotation based XML Marshalling in Spring Boot
In my spring boot application, I have below DTO class
@Data
public clsss Feed {
private int id;
private String name;
private String title;
@Builder
@XmlRootElement(name = &...
0
votes
0
answers
250
views
spring app fails to start after adding the dependency jackson-dataformat-xml
I am running a spring boot application 2.5.6 and I have the following issue:
after adding the dependency jackson-dataformat-xml to my pom.xml the application fails to start failing on initializing one ...
0
votes
1
answer
837
views
Spring XML to object mapping returns "Content type 'application/xml' not supported for bodyType=..."
I have an endpoint (GET localhost:8080/api/getPerson), which should map the request body into an object. It works well when I send a body as JSON but when sending a XML I get a Unsupported Media Type (...
0
votes
1
answer
277
views
How to get XML element attribute values in single quotes in REST API XML response?
REST API produces the response in JSON and XML format. I am using Jackson to get XML elements as required but when I use @JacksonXmlProperty(isAttribute = true), values get in double quotes; how to ...
1
vote
1
answer
159
views
Jackson-alternative to SimpleXML's @ElementListUnion
Serializing a list that may contain elements with different types in Java using SimpleXML, you can you something such as
class Root {
@ElementListUnion({
@ElementList(entry = "Foo", ...