This repository has been archived on 2021-11-25. You can view files and clone it, but cannot push or open issues or pull requests.
BookFloatingServer/JsonStudy.java

53 lines
993 B
Java

import com.google.gson.Gson;
class RegisterData
{
private String email;
private String nickname;
private String pwass;
private String school;
public String getEmail()
{
return email;
}
public void setEmail(String Email)
{
email=Email;
}
public String getNickname()
{
return nickname;
}
public void setNickname(String Nickname)
{
nickname=Nickname;
}
public String getPass()
{
return pwass;
}
public void setPass(String Pwass)
{
pwass=Pwass;
}
public String getSchool()
{
return school;
}
public void setSchool(String School)
{
school=School;
}
}
public class JsonStudy
{
public static void main(String[] args)
{
String jsonData="{'email':'test@163.com','nickname':'Kirito','school':'QUST','pwass':'dvaLovesU'}";
Gson gson=new Gson();
RegisterData data=gson.fromJson(jsonData, RegisterData.class);
System.out.println("Email:"+data.getEmail()+" NickName:"+data.getNickname()+" School:"+data.getSchool()+" Password:"+data.getPass());
}
}