I have following data structure:
Class UserModel {
Long pkid;
String name;
public UserModel() {
this.pkid = new Long(1001);
this.name = "ABC";
}
}
Now I have converted this into json:
UserModel usrObj = new UserModel();
Gson gson = new Gson();
String json = gson.toJson(userObj);
So my json string is now like:
{ "pkid": 1001,
"name": "ABC" }
But I need to create the json as
{"com.vlee.ejb.UserModel": [
{ "pkid": 1001,
"name": "ABC" } ] }
I am not sure how I can add the key "com.vlee.ejb.UserModel"
.
forums.androidcentral.com
No comments:
Post a Comment