Comments (6)
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.
Ok. Thanks for your answer.
from gson-xml.
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.
Yeah, it seems to be ok.
from gson-xml.
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.
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)
- Enable to parse primitive list with same names when param exist in the root tag HOT 9
- Cannot deserialize elements with optional attributes HOT 2
- How to deserialize duplicate tags HOT 4
- Add XML serialization capability
- Array deserealization HOT 6
- How should I model this?
- Do not use "$" for text nodes HOT 2
- Deserializing error HOT 3
- Unable to use this library into eclipse android project
- Deserializing with setSameNameLists(true) fails with JsonSyntaxException HOT 3
- Self-closing tag, xml to pojo fail HOT 4
- com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: BEGIN_OBJECT expected, but met STRING HOT 2
- Unable to parse array located at 3rd level of nested xml com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: BEGIN_OBJECT expected, but met NAME HOT 2
- custom same name nodes in xml not deserializable
- need advice
- Question: Can I produce XML with a Gson object?
- BEGIN_OBJECT expected, but met NAME HOT 1
- support android xml binary resource HOT 1
- Deserializing an array HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gson-xml.