package toonyoo.ums.test;import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.google.gson.annotations.Since;public class User {   
    
    public User(String string, String string2, String string3, String string4) {
        // TODO Auto-generated constructor stub
        this.username=string;
        this.password=string2;
        this.gender=string3;
        this.sex=string4;
    }
    @SerializedName("pwd")  
    private String password;   
    @Expose  
    @SerializedName("uname")  
    private String username;   
    @Expose  
    @Since(1.1)  
    private String gender;   
    @Expose  
    @Since(1.0)  
    private String sex;
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getGender() {
        return gender;
    }
    public void setGender(String gender) {
        this.gender = gender;
    }
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex;
    }  }  调用:
        List<User> userList = new ArrayList<User>();  
        User jack = new User("123456","Jack", "Male","Female");   
        User marry = new User("888888","Marry", "Female","Male");   
        userList.add(jack);   
        userList.add(marry);   
        Gson son=new Gson();
        Type targetType = new TypeToken<List<User>>() {}.getType();          String str=son.toJson(userList, targetType);
        /*[{"pwd":"Jack","uname":"123456","gender":"Male","sex":"Female"},{"pwd":"Marry","uname":"888888","gender":"Female","sex":"Male"}]*/
        users =son.fromJson(str,targetType);///转换失败,提示下面的错误
执行结果提示“Exception in thread "main" com.google.gson.JsonParseException”搞得相当的郁闷,有碰到的指点一下!
哪个大虾有GSON源码或下载地址也行,我在gson主页上发现只能在线查看代码。