I have a POJO like this, which I serialize to JSON using GSON:
public class ClientStats {
private String clientId;
private String clientName;
private String clientDescription;
}
Here is how I do it:
ClientStats myPojo = new ClientStats();
Gson gson = new Gson();
gson.toJson(myPojo);
Now my json will be as follows:
{"clientId":"100", ...... }
Now my question is: is there a way to create my own name for clientIdinstead of changing the variable name clientId? Is there any annotation in Gson that I can use here on top of a variable clientId?
I need something like this:
{"client_id":"100", ...... }
source
share