john
john

Reputation: 11669

serialize json to pojo class

I have a JSON response coming as shown below. I am trying to make a POJO for this so that I can serialize this JSON into my POJO.

{
    "holder": [
        {
            "ids": [
                {
                    "data": "abcdef1234",
                    "time": 1452720139465,
                    "days": 16813
                },
                {
                    "data": "abcdef12345678",
                    "time": 1452720139465,
                    "days": 16813
                },
                {
                    "data": "abcdef12345678901234",
                    "time": 1452720139465,
                    "days": 16813
                }
            ],
            "type": "HELLO"
        }
    ]
}

And this is my POJO I was able to come up with but it doesn't look right.

public class TestResponse {

    private List<Ids> holder;
    private String type;

    // getters and setters

    public static class Ids {
        private String data;
        private long time;
        private long days;

        // getters and setters
    }
}

My json is not getting serialized to my above POJO

Upvotes: 0

Views: 237

Answers (1)

Dhaval Joshi
Dhaval Joshi

Reputation: 56

go to this link www.jsonschema2pojo.org and past yout json and extract jar files and import in your project and do some changes link this.

$class TestResponse { 
to 
class TestResponse implement serializable{ 

Upvotes: 1

Related Questions