JSON To Object Gson Library

suggest change

Lets assume you have a class called Person with just name

private class Person {
    public String name;

    public Person(String name) {
        this.name = name;


Gson gson = new Gson();
String json = "{\"name\": \"John\"}";

Person person = gson.fromJson(json, Person.class);
System.out.println(person.name); //John

You must have gson library in your classpath.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents