Sarthak Gupta
Sarthak Gupta

Reputation: 392

POJO for api response which has key with '-'

My api response return following response body. I have to create a POJO for this api response.

 {
            "time-since-created": 115,
            "img_url": "<Image url>",
            "heading": "Waiting for image upload",
            "name": "How are you?",
    }

Private variables for other 3 will be

private String img_url;
private String heading; 
private String img_url;

But the variable for time-since-created gives an error

Can not deserialize instance

Upvotes: 1

Views: 72

Answers (1)

lakhansoren
lakhansoren

Reputation: 172

Use @JsonProperty :

@JsonProperty("time-since-created")
private Integer timeSinceCreated;

Upvotes: 2

Related Questions