Deserialize json to java using jackson - issues with special characters

风流意气都作罢 提交于 2019-12-02 07:09:31

问题


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.


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!