-
-
Notifications
You must be signed in to change notification settings - Fork 228
Error when desirializing the result of serialization #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Could you also include definition of |
Movie import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@JacksonXmlRootElement(localName = "movie")
@JsonIgnoreProperties(ignoreUnknown = false)
public class Movie {
@JacksonXmlProperty(isAttribute = true)
private final String imdbID;
@JacksonXmlProperty(isAttribute = true)
private final String title;
@JacksonXmlProperty(isAttribute = true)
private int year;
@JsonCreator
public Movie(@JsonProperty("imdbID") String id,
@JsonProperty("title") String title, @JsonProperty("year") int year) {
this.imdbID = id;
this.title = title;
this.year = year;
}
public String getId() {
return imdbID;
}
public String getTitle() {
return title;
}
public int getYear() {
return year;
}
public String toString() {
return title;
}
} Movies import java.util.List;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@JacksonXmlRootElement(localName = "root")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(Include.NON_NULL)
public class Movies {
@JacksonXmlElementWrapper(useWrapping = false)
@JacksonXmlProperty(localName = "movie")
private List<Movie> movies;
@JsonProperty("error")
private String error;
@JacksonXmlProperty(isAttribute = true)
private boolean response;
public Movies() {
}
@JsonCreator
public Movies(List<Movie> movies) {
this.movies = movies;
}
public List<Movie> getMovies() {
return movies;
}
public String getError() {
return error;
}
@JsonProperty("error")
public void setError(String error) {
this.error = error;
}
public void setResponse(boolean response) {
this.response = true;
}
public String toString() {
return movies.toString();
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a strange problem with deserializing xml into a POJO. I have this test:
The serialisation works fine but when I try to deserialize the obtained xml I get this error:
When I do the desrialization of this xml:
I get the same error about
response
attribute even though response is part of the root element not the movie element. Normally response is member of the classMovies
notMovie
so why I get the error?The text was updated successfully, but these errors were encountered: