import com.owlike.genson.Genson;
public class JsonParser {
public static void main(String[] args) {
String json = "{\"name\":\"John\", \"age\":30, \"city\":\"New York\"}";
Genson genson = new Genson();
Person person = genson.deserialize(json, Person.class);
System.out.println(person.getName());
System.out.println(person.getAge());
System.out.println(person.getCity());
}
static class Person {
private String name;
private int age;
private String city;
}
}
import com.owlike.genson.Genson;
public class JsonGenerator {
public static void main(String[] args) {
Person person = new Person("John", 30, "New York");
Genson genson = new Genson();
String json = genson.serialize(person);
System.out.println(json);
}
static class Person {
private String name;
private int age;
private String city;
public Person(String name, int age, String city) {
this.name = name;
this.age = age;
this.city = city;
}
}
}