Gson是谷歌开源的用于处理json格式数据的工具.
使用Gson需要引入第三方jar包:
package Exercise1_gson;
import java.io.Serializable;
/**
* @author huangxinyi
* 实体类product
*
*/
public class Product implements Serializable {
private static final long serialVersionUID = -899351582186856010L;
private String brand;
private String type;
private String color;
private float price;
public Product(){}
public Product(String brand, String type, String color, float price) {
this.brand = brand;
this.type = type;
this.color = color;
this.price = price;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getColor() {
r