import com.google.gson.Gson;
public class JsonParser {
public static void main(String[] args) {
String json = "{\"name\":\"Alice\",\"age\":30}";
Gson gson = new Gson();
Person person = gson.fromJson(json, Person.class);
System.out.println("Name: " + person.getName());
System.out.println("Age: " + person.getAge());
}
static class Person {
private String name;
private int age;
public String getName() {
return name;
}
public int getAge() {
return age;
}
}
}
顶一下
(0)
0%
踩一下
(0)
0%
- 相关评论
- 我要评论
-
上一篇:返回栏目
下一篇:java微信扫二维码登录接口