Search code examples
javajsonpojo

What is the POJO equivalent for this nested json?


There is a json response of a webservice :

{
  "data": {
            "token": "e3a5776e-bf55-4bf8-a6e3-008c849089da"
          },
  "error": null
}

I want to make a POJO for it ; what should be its structure ?


Solution

  • Assuming error is an Object, following is the POJO.

    public class Data{
        public String token;
    }
    
    public class MainObj{
        public Data data;
        public Object error;
    }