Answer the question
In order to leave comments, you need to log in
How to get the value of an object in the model?
I don’t understand how to pull out the width value
There is an object
{
size: {
width: 100,
height: 120
}
}
public class Document {
@SerializedName("size")
@Expose
private JSONObject size;
public JSONObject getSize() {
return size;
}
}
Document document = new Gson().fromJson(json, Document.class);
Log.d(TAG, "size: " + document.getSize()); // size: {}
Answer the question
In order to leave comments, you need to log in
Why is everything so bold)
I had to create another model Size.java
public class Size {
@SerializedName("width")
@Expose
private String width;
@SerializedName("height")
@Expose
private String height;
public String getWidth() {
return width;
}
public String getHeight() {
return height;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question