I am using jackson (jersey and jetty) for my REST webservices - and all is going well. But I have a requirement to include a special character in one of the name value pairs in json post request. i.e. json request (in post body)-
{
"id": "1",
"print-color" : "red"
}
//"-" in "print-color" is giving problems.
Now inside my corresponding java bean for this object Item.java class, I cant make a property with name print-color (because "-" is not allowed). How do I deal with it in mapping?
Thanks.
You could try following in Java POJO:
@JsonProperty("print-color")
来源:https://stackoverflow.com/questions/18962698/deserialize-json-to-java-using-jackson-issues-with-special-characters