Skip to content

Instantly share code, notes, and snippets.

@NLMartian
Last active December 27, 2015 01:38
Show Gist options
  • Save NLMartian/7246003 to your computer and use it in GitHub Desktop.
Save NLMartian/7246003 to your computer and use it in GitHub Desktop.
public class JamNotification {
@SerializedName("wall_comment")
public JamFeedComment feedComment = new JamFeedComment();
/* Variable name for internal use */
@SerializedName("member_id")
private int memberId;
@SerializedName("obj_id")
private int objId;
// if the json key is equase the field name, we needn't this anotation //@SerializedName("id")
private int id;
@SerializedName("sender_id")
private int senderId;
// wrapper class
public class JamFeedComment {
private String comment;
@SerializedName("feed_id")
private int feedId;
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public int getFeedId() {
return feedId;
}
public void setFeedId(int i) {
this.feedId = i;
}
}
public static void main(args[]) {
// Simple fromJson, toJson API
private Gson gson = new Gson();
JamNotification notification = new JamNotification();
// set fields…
String jsonStr = gson.toJson();
JamNotification notification1 = gson.fromJson(jsonStr, JamNotification.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment