FroMage/jax-doclets — Issue #23: Provide switch to omit @ in JSON mapped XML attributes
Author: stanio
Created: 2012-01-03 02:00:17+00:00
State: open

Jackson supports mapping Java Beans to/from JSON using JAXB annotations:

http://wiki.fasterxml.com/JacksonJAXBAnnotations

Its mapping is really simple and doesn't try to distinguish XML features like attributes (vs. elements) and namespaces, so both of the following two versions:

public class Foo {

@XmlElement
public String bar;

@XmlElement
public String baz;

}

and:

public class Foo {

@XmlAttribute
public String bar;

@XmlElement
public String baz;

}

get serialized as:

{
"bar" : "...",
"baz" : "..."
}

and not as:

{
"@bar" : "...",
"baz" : "..."
}

It would be nice if there's an option to omit the @ in attribute names in the generated JSON examples, e.g. -useplainjsonattributenames, though this is a bit lengthy one.