接下来将使用GSON作为本项目的JSON解析器
This commit is contained in:
parent
a428abe334
commit
7c8bfad30f
53
JsonStudy.java
Normal file
53
JsonStudy.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user