Can you post some sample JSON you are trying to parse with Jackson?
The exception you are receiving makes it sound like your JSON is something like
{
"@Graphic" : "value"
}
That is, @Graphic is a field name that its trying to find a field for in your POJO. Seems strange to have a field beginning with @, but it appears to be valid JSON otherwise Jackson would not like it.
In general, you can tell Jackson to map a JSON field to a POJO field with a different name by using the @JsonProperty annotation, this may be what you are looking for
@JsonProperty("@Graphic")
public Object getGraphic() {
...
}
--joe
[Velti]<
http://www.velti.com> Joseph Mocker | Senior Software Architect
t +1.650.566.7033 m +1.650.566.7033
e jmocker@velti.com @Mobclix<
http://twitter.com/Mobclix>
[cid:sep11117bd707]
The leading global technology provider of
mobile marketing and advertising solutions
<
http://mwc.velti.com/meet-us>
On Oct 2, 2013, at 7:44 AM, feldberg ian wrote:
Hi. I'm using Jersey 1.x to serve up some JAXB-annotated Java objects through a REST endpoint. When I request these objects in JSON format (application/json) they correctly get served, that is, fields in the object annotated as @XmlAttribute's have an at sign prepended to their name. Then when I PUT or POST those strings back to the REST endpoint, they get correctly parsed as attributes and not XML elements. Good Jersey.
Now, I need to be able to parse JSON strings into JAXB Java objects without the REST endpoint. I will be getting the strings directly from JavaScript. I've read conflicting information about which JSON Provider (MOXy, Jackson, Jettison) Jersey uses so I started with Jackson. I created an ObjectMapper and even set the AnnotationIntrospector to only use JAXB but I still get the exception:
org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "@Graphic" not marked as ignorable
Well I'm not going to mark it as ignorable because I don't want it ignored! I want it interpreted as an XML attribute! I thought about not setting the @ in the first place but these JAXB classes get generated from an XML schema controlled by another group so I can't exactly change the schema to not have attributes.
Is there a flag in Jackson that will allow me to parse strings that start with an "@" as attributes? Am I barking up the wrong tree? Maybe Jersey 1.x doesn't use Jackson as I was told...