简体   繁体   中英

How to map Json Object with Hyphen to Java Object

We are integrating Restful webservice in existing application which uses IBM Websphere application server(RAD 7) and compiler is 5.0.

Now i have a situation where i am getting json data attribute with -. (my-name). I am using jackson json api (using jersey jar files 1.2 as it is Java 5) to map json data to java objects.

Tried using @JsonProperty to get the corresponding JSON property. Object is getting initialized but property value is null.

class Person {

    @JsonProperty("first-name")
    private String firstName;

    @JsonProperty("last-name")
    private String lastName;

}

No exception but firstname and lastname value is null or empty.

@JsonProperty 完成这项工作,我遇到了与您相同的问题,并且使用注释解决了它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM