简体   繁体   English

将json序列化为pojo类

[英]serialize json to pojo class

I have a JSON response coming as shown below. 我有一个JSON响应,如下所示。 I am trying to make a POJO for this so that I can serialize this JSON into my POJO. 我正在尝试为此创建一个POJO,以便可以将此JSON序列化到我的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. 这是我能想到的POJO,但看起来不正确。

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 我的json没有序列化到我上面的POJO

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. 转到此链接www.jsonschema2pojo.org并过去yout json并提取jar文件并导入您的项目中,并进行一些更改以链接到此。

$class TestResponse { 
to 
class TestResponse implement serializable{ 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM