Excel表格网

java json接口

281 2024-03-10 09:03 admin   手机版
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%
相关评论
我要评论
用户名: 验证码:点击我更换图片