<dependencies> <dependency> <groupId>com.jsonty</groupId> <artifactId>jsonty</artifactId> <version>1.0.0</version> </dependency> </dependencies> import com.jsonty.JsonObject; import com.jsonty.JsonParser; String json = "{\"name\":\"John\", \"age\":25}"; JsonObject jsonObject = JsonParser.parse(json).getAsJsonObject(); String name = jsonObject.get("name").getAsString(); int age = jsonObject.get("age").getAsInt(); import com.jsonty.JsonObject; import com.jsonty.JsonCreator; class Person { private String name; private int age; public Person(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public int getAge() { return age; } } Person person = new Person("John", 25); JsonObject jsonObject = JsonCreator.create(person); String json = jsonObject.toString();


上一篇:
下一篇:
切换中文