Code Monkey home page Code Monkey logo

Comments (6)

roman-mazur avatar roman-mazur commented on August 11, 2024

In the first case your xml is mapped to stream of json tokens representing the following structure:

//...
element : {
  tag : "second",
  thumbnail_hq : {
    hundred_fifty_square : "...",
    // ...
  }
}

which can be correctly mapped yo your objects model.

In the second case JSON created from XML stream is the following:

// ...
element : {
  tag : "second",
  thumbnail_hq : ""
}

And you get the error.

Again this is caused by the fact that parser does not know anything about your target objects model. It just converts stream of XML tokens to JSON tokens.
The easiest solution might be to completely exclude thumbnail_hq tag from incoming XML structure when it's empty. It'll also reduce amount of data you process and traffic.
If it's not possible, you might use a custom type adapter for Thumb.

from gson-xml.

DenBond7 avatar DenBond7 commented on August 11, 2024

Ok. Thanks for your answer.

from gson-xml.

DenBond7 avatar DenBond7 commented on August 11, 2024

Hello. Can we get a next variant?

// ...
element : {
  tag : "second",
  thumbnail_hq : null
}

Than as "thumbnail_hq" will be null and we will not get error.

from gson-xml.

roman-mazur avatar roman-mazur commented on August 11, 2024

Yeah, it seems to be ok.

from gson-xml.

DenBond7 avatar DenBond7 commented on August 11, 2024

Ok. Do you have any idea how to modify the gson-xml library to get null value for an empty tag (<thumbnail_hq/>)? Maybe we can use isEmptyElementTag () for XmlPullParser?

from gson-xml.

boomsya avatar boomsya commented on August 11, 2024

today i have the same error
my xml node:
<FAX xsi:nil = "true"/>

does someone have ideas how to parse this nodes?

from gson-xml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.