FasterXML / jackson-dataformat-xml

Extension for Jackson JSON processor that adds support for serializing POJOs as XML (and deserializing from XML) as an alternative to JSON
Apache License 2.0
567 stars 221 forks source link

Simillar elements inside are skipped #610

Open aivanovski opened 1 year ago

aivanovski commented 1 year ago

XmlMapper just skips elements inside element with resource-id="com.ivanovsky.passnotes:id/recyclerView". File is attached. There is also no warnings, errors or any kind messages after XmlMapper().readValue() call.

version 2.15.2

groups-screen-invalid-dump.xml.txt

cowtowncoder commented 1 year ago

@aivanovski This explanation is not sufficient to understand what your problem is -- please include code you are using, with expectations of what you thing should happen. Ideally in a form of a test case. As is, I don't know what "Similar" here means, for example, nor why you think an expection ought to be thrown (Jackson does not use logging so no warnings would ever result).

aivanovski commented 1 year ago

Some elements inside XML file aren't parsed, they are skipped during XmlMapper().readValue() call. These skipped elements are located inside element with resource-id="com.ivanovsky.passnotes:id/recyclerView" where resource-id is an XML attribute inside one of XML elements of the attached XML file. @cowtowncoder

pjfanning commented 1 year ago

Some elements inside XML file aren't parsed, they are skipped during XmlMapper().readValue() call. These skipped elements are located inside element with resource-id="com.ivanovsky.passnotes:id/recyclerView" where resource-id is an XML attribute inside one of XML elements of the attached XML file. @cowtowncoder

@aivanovski you haven't provided a meaningful example. There is no need to keep posting the same sparse details - they are not sufficient.

aivanovski commented 1 year ago

I supposed you guys at least try to parse attached file, but ok, that's honest enough. It's Kotlin. Inside the deserilized result (data variable), there is a node with resourceId=com.ivanovsky.passnotes:id/recyclerView it doesn't have a children, but xml file has children.

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonRootName
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule
import com.fasterxml.jackson.dataformat.xml.XmlMapper
import java.io.File

fun main(args: Array<String>) {
    val data = XmlMapper(JacksonXmlModule())
        .readValue(
            File("groups-screen-invalid-dump.xml.txt"),
            Hierarchy::class.java
        )
}

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonRootName("node")
class Node {
    @set:JsonProperty("resource-id", required = false)
    var resourceId: String? = null

    @set:JsonProperty("text", required = false)
    var text: String? = null

    @set:JsonProperty("node", required = false)
    var nodes: List<Node> = mutableListOf()
}

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonRootName("hierarchy")
class Hierarchy {
    @set:JsonProperty("rotation", required = false)
    var rotation: Int? = null

    @set:JsonProperty("node", required = false)
    var nodes: List<Node> = mutableListOf()
}
aivanovski commented 1 year ago

Java code also has the same issue. JacksonTestJava.java.txt