Gson解析json的纯数组

数据的格式:

[{

    "spoken_id": 43,
    "width": 0.429,
    "height": 0.076,

}, {
    "spoken_id": 44,
    "width": 0.338,

    "height": 0.086,  

}

}]

public class DianduData {
    private int spoken_id;
    private String width;
    private String height;
 
    public int getSpoken_id() {
        return spoken_id;
    }

    public void setSpoken_id(int spoken_id) {
        this.spoken_id = spoken_id;
    }

    public String getWidth() {
        return width;
    }

    public void setWidth(String width) {
        this.width = width;
    }

    public String getHeight() {
        return height;
    }

    public void setHeight(String height) {
        this.height = height;
    }

 }

解析数据

Type listType = new TypeToken>(){}.getType();
Gson gson = new Gson();
LinkedList result = gson.fromJson(data, listType);


你可能感兴趣的:(Android)