Saturday, 15 September 2012

java - GSON @SerializedName to get value from inner array in json -



java - GSON @SerializedName to get value from inner array in json -

this json

{ name: "mark" subject: "maths" phone: 123-456-7890 email_addresses: [ { email: "mark@example.com", is_primary: true } ] }

my java class goes this

public class pupil { @serializedname("name") private string mname; @serializedname("subject") private string msubject; @serializedname("phone") private string mphone; private string memail; }

is there way utilize @serializedname memail, able email field first object in email_addresses array

no, there isn't. either create own typeadapter or create pojo type email addresses , have student declare field of type list of whatever pojo type is. provider getter retrieve first email (if there one).

java json gson

No comments:

Post a Comment