我要问的下一个问题,是我的亲善大使。
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
/**
* @author Martin Burchard
*
*/
@XmlRootElement(name = "user")
@XmlAccessorType(XmlAccessType.FIELD)
public class User {
private String id;
private String nickname;
private String email;
private String password;
private Map<String, String> user_attributes;
}
Currently the service delivers the following JSON (indented for better reading):
{
"user" : {
"id" : "9bdf40ea-6d25-4bc3-94ad-4a3d38d2c3ca",
"email" : "[email protected]",
"password" : "xXpd9Pl-1pFBFuX9E0hAYGSDTyJQPYkOtXGvRCrEtMM",
"user_attributes" : {
"entry" : [{
"key" : "num",
"value" : 123
}, {
"key" : "type",
"value" : "nix"
}
]
}
}
}
The funny think is, internally the num 123 is a java.lang.String...
我不理解这里解释的内容:http://cxf.apache.org/docs/jax-rs-data- bindings.html#JAX-RSDataBleds-Dealing withJSONarrayserializationissues”rel=“nofollow” http://cxf.apache.org/docs/jax-rs-data- bindings.html#JRP-RSDataBelles-Dealing withJarraSONyserializationissues 。
我谨请各位:
{
"user" : {
"id" : "9bdf40ea-6d25-4bc3-94ad-4a3d38d2c3ca",
"email" : "[email protected]",
"password" : "xXpd9Pl-1pFBFuX9E0hAYGSDTyJQPYkOtXGvRCrEtMM",
"user_attributes" : {
"num" : "123",
"type" : "nix"
}
}
}
I changed the JSON provider to Jackson. Now my JSON looks like I like it...