我想更改字段的名称:
public class Track {
@JsonProperty("title2")
private String title;
...}
我有这个方法:
@Path("/json/metallica")
public class MyRest {
@GET
@Path("/get")
@Produces(MediaType.APPLICATION_JSON)
public Track getTrackInJSON() {
Track track = new Track();
track.setTitle("Enter Sandman");
track.setSinger("Metallica");
return track;
}
调用方法后,我希望看到
{"singer":"Metallica","title2":"Enter Sandman"}
但是有:
{"singer":"Metallica","title":"Enter Sandman"}
我做错了什么?......似乎应该有效......