Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Jackson映射器未映射所有字段_Java_Spring Boot_Jackson - Fatal编程技术网

Java Jackson映射器未映射所有字段

Java Jackson映射器未映射所有字段,java,spring-boot,jackson,Java,Spring Boot,Jackson,我使用jackson将我的POJO数组转换为json,但它没有在输出中提供一个特定字段,其中as gson.toJson提供输出。有人能帮忙吗 public class TestCenter implements Comparable<TestCenter>{ private Integer no_of_accessible_tests=0; private Integer tagId; private String tag; private In

我使用jackson将我的POJO数组转换为json,但它没有在输出中提供一个特定字段,其中as gson.toJson提供输出。有人能帮忙吗

public class TestCenter implements Comparable<TestCenter>{


    private Integer no_of_accessible_tests=0;
    private Integer tagId;
    private String tag;
    private Integer number_of_tests=0;

    private List<Test> tests= new ArrayList<>();

    public Integer getTagId() {
        return tagId;
    }
    public void setTagId(Integer tagId) {
        this.tagId = tagId;
    }
    public String getTag() {
        return tag;
    }
    public void setTag(String tag) {
        this.tag = tag;
    }
    public Integer getNumber_of_tests() {
        return number_of_tests;
    }
    public void setNumber_of_tests(Integer number_of_tests) {
        this.number_of_tests = number_of_tests;
    }
    public List<Test> getTests() {
        return tests;
    }
    public void setTests(List<Test> tests) {
        this.tests = tests;
    }

    public void addTest(Test t)
    {

        this.tests.add(t);
        this.number_of_tests++;
        if("Yes".equals(t.getAccess()))
            this.no_of_accessible_tests++;
    }
    @Override
    public int compareTo(TestCenter o) {

        if(this.no_of_accessible_tests.equals(o.no_of_accessible_tests))
        {
            return number_of_tests.compareTo(o.number_of_tests);
        }
        else
        {
            return o.no_of_accessible_tests.compareTo(this.no_of_accessible_tests);
        }
    }


}

System.out.println(gson.toJson(tests));
          System.out.println(mapper.writeValueAsString(tests));
          return mapper.writeValueAsString(tests);
output for both:
[{"no_of_accessible_tests":0,"tagId":196,"tag":"IBPS Clerical Prelims","number_of_tests":1,"tests":[{"activatedDate":null,"activatedTime":null,"ScheduleDate":null,"ScheduleTime":null,"endDate":null,"endTime":null,"testId":2193,"testCode":"P15 CP FLT 61","testName":"Amazon -4","testType":"flt","testPattern":"ibps","testDurationInMinutes":120,"numberOfQuestions":104,"access":"No","status":"start","testResult":null,"tags":["2017","IBPS Clerical Prelims"]}]},{"no_of_accessible_tests":0,"tagId":0,"tag":"Others","number_of_tests":6,"tests":[{"activatedDate":null,"activatedTime":null,"ScheduleDate":null,"ScheduleTime":null,"endDate":null,"endTime":null,"testId":2525,"testCode":"CP 16 FLT 04","testName":"Tech Mahindra -4","testType":"flt","testPattern":"ibps","testDurationInMinutes":65,"numberOfQuestions":76,"access":"No","status":"start","testResult":null,"tags":null},{"activatedDate":"2015-12-17","activatedTime":"09:00:00","ScheduleDate":"2015-12-17","ScheduleTime":"09:00:00","endDate":"license end date","endTime":"license end time","testId":2188,"testCode":"P15 CP FLT 58","testName":"Amazon -1","testType":"flt","testPattern":"ibps","testDurationInMinutes":120,"numberOfQuestions":104,"access":"No","status":"Resume","testResult":null,"tags":null},{"activatedDate":"2015-12-17","activatedTime":"09:00:00","ScheduleDate":"2015-12-17","ScheduleTime":"09:00:00","endDate":"license end date","endTime":"license end time","testId":2190,"testCode":"P15 CP FLT 59","testName":"Amazon -2","testType":"flt","testPattern":"ibps","testDurationInMinutes":120,"numberOfQuestions":104,"access":"No","status":"start","testResult":null,"tags":null},{"activatedDate":null,"activatedTime":null,"ScheduleDate":null,"ScheduleTime":null,"endDate":null,"endTime":null,"testId":2192,"testCode":"P15 CP FLT 60","testName":"Amazon -3","testType":"flt","testPattern":"ibps","testDurationInMinutes":120,"numberOfQuestions":104,"access":"No","status":"start","testResult":null,"tags":null},{"activatedDate":null,"activatedTime":null,"ScheduleDate":null,"ScheduleTime":null,"endDate":null,"endTime":null,"testId":1929,"testCode":"P15 CP FLT 09","testName":"CapGemini -1","testType":"flt","testPattern":"ibps","testDurationInMinutes":60,"numberOfQuestions":75,"access":"No","status":"start","testResult":null,"tags":null},{"test_ready":"no","reason_student_side":"This test would be available on 22-Dec-16.","reason_admin_side":".","testId":2633,"testCode":"BP FLT 87","testName":"SBI Specialist Officer Test -5","testType":"flt","testPattern":"ibps","testDurationInMinutes":90,"numberOfQuestions":120,"access":"No","status":"start","testResult":null,"tags":null}]}]
[{"tagId":196,"tag":"IBPS Clerical Prelims","number_of_tests":1,"tests":[{"testId":2193,"testCode":"P15 CP FLT 61","testName":"Amazon -4","testType":"flt","testPattern":"ibps","testDurationInMinutes":120,"numberOfQuestions":104,"access":"No","status":"start","testResult":null,"tags":["2017","IBPS Clerical Prelims"],"activatedDate":null,"activatedTime":null,"endDate":null,"endTime":null,"scheduleDate":null,"scheduleTime":null}]},{"tagId":0,"tag":"Others","number_of_tests":6,"tests":[{"testId":2525,"testCode":"CP 16 FLT 04","testName":"Tech Mahindra -4","testType":"flt","testPattern":"ibps","testDurationInMinutes":65,"numberOfQuestions":76,"access":"No","status":"start","testResult":null,"tags":null,"activatedDate":null,"activatedTime":null,"endDate":null,"endTime":null,"scheduleDate":null,"scheduleTime":null},{"testId":2188,"testCode":"P15 CP FLT 58","testName":"Amazon -1","testType":"flt","testPattern":"ibps","testDurationInMinutes":120,"numberOfQuestions":104,"access":"No","status":"Resume","testResult":null,"tags":null,"activatedDate":"2015-12-17","activatedTime":"09:00:00","endDate":"license end date","endTime":"license end time","scheduleDate":"2015-12-17","scheduleTime":"09:00:00"},{"testId":2190,"testCode":"P15 CP FLT 59","testName":"Amazon -2","testType":"flt","testPattern":"ibps","testDurationInMinutes":120,"numberOfQuestions":104,"access":"No","status":"start","testResult":null,"tags":null,"activatedDate":"2015-12-17","activatedTime":"09:00:00","endDate":"license end date","endTime":"license end time","scheduleDate":"2015-12-17","scheduleTime":"09:00:00"},{"testId":2192,"testCode":"P15 CP FLT 60","testName":"Amazon -3","testType":"flt","testPattern":"ibps","testDurationInMinutes":120,"numberOfQuestions":104,"access":"No","status":"start","testResult":null,"tags":null,"activatedDate":null,"activatedTime":null,"endDate":null,"endTime":null,"scheduleDate":null,"scheduleTime":null},{"testId":1929,"testCode":"P15 CP FLT 09","testName":"CapGemini -1","testType":"flt","testPattern":"ibps","testDurationInMinutes":60,"numberOfQuestions":75,"access":"No","status":"start","testResult":null,"tags":null,"activatedDate":null,"activatedTime":null,"endDate":null,"endTime":null,"scheduleDate":null,"scheduleTime":null},{"testId":2633,"testCode":"BP FLT 87","testName":"SBI Specialist Officer Test -5","testType":"flt","testPattern":"ibps","testDurationInMinutes":90,"numberOfQuestions":120,"access":"No","status":"start","testResult":null,"tags":null,"test_ready":"no","reason_student_side":"This test would be available on 22-Dec-16.","reason_admin_side":"."}]}]
公共类TestCenter实现了可比较的{
可访问测试的私有整数编号=0;
私有整数tagId;
私有字符串标签;
_测试的私有整数_=0;
私有列表测试=新建ArrayList();
公共整数getTagId(){
返回标记ID;
}
public void setTagId(整型tagId){
this.tagId=tagId;
}
公共字符串getTag(){
返回标签;
}
公共void setTag(字符串标记){
this.tag=tag;
}
公共整数getNumber of_tests(){
返回测试的次数;
}
公共无效集合测试的数量(测试的整数){
这是。测试次数=测试次数;
}
公共列表getTests(){
回归测试;
}
公共无效设置测试(列表测试){
这个。测试=测试;
}
公共测试(测试t)
{
本.试验.添加(t);
这个。测试的数量++;
如果(“是”。等于(t.getAccess())
这个。没有可访问的测试++;
}
@凌驾
公共int比较(测试中心o){
if(这是可访问测试的数量等于(可访问测试的数量))
{
返回测试的数量。比较(o.测试的数量);
}
其他的
{
返回o.no\u of_accessible\u tests.compareTo(此为.no\u of_accessible\u tests);
}
}
}
System.out.println(gson.toJson(tests));
System.out.println(mapper.writeValueAsString(tests));
返回mapper.writeValueAsString(测试);
两者的输出:
[{“no_of_accessible_tests”:0,“tagId”:196,“tag”:“IBPS文书预备”、“数量_tests”:1,“tests”:[{“activatedate”:null,“activatedTime”:null,“ScheduleDate”:null,“scheduledtime”:null,“endDate”:null,“endTime”:null,“testId”:2193,“testCode”:“P15 CP FLT 61”,“testName”:“Amazon-4”,“testType”:“FLT”,“testPattern”:“IBPS”,“testDurationInMinutes”:120,“numberOfQuestions”:104,“access:“No”,“status:“start”,“testResult:”null,“tags:”[“2017”,“IBPS文书预备课”]}],{“No_of_accessible__tests:”0,“tagId:”0,“tag:”Others”,“number of_tests:”6,“tests:”[{“activatedDate:”null,“activatedTime:”null,“ScheduleDate:”null,“ScheduleTime:”null,“endDate:”null,“endTime:”null,“testId:”2525,“testCode:”CP 16 FLT 04“,”testName“:”Tech Mahindra-4“,”testType“:”flt“,”testPattern“:”ibps“,”testDurationInMinutes“:”65,“numberOfQuestions“,”access“,”否“,”状态“,”开始“,”testResult“,”空“,”标签“:”空“,”激活日期“:”09:00:00“,”时间表日期“:”2015-12-17“,”时间表时间“:”09:00:00:00“,”结束日期“,”结束日期“,”结束时间“,”,“testId”:2188,“testCode”:“P15 CP FLT 58”,“testName”:“Amazon-1”,“testType”:“FLT”,“testPattern”:“ibps”,“testDurationInMinutes”:120,“numberOfQuestions”:104,“access”:“No”,“status”:“Resume”,“testResult”:null,“tags”:null},{“activatedDate”:“2015-12-17”,“activatedTime”:“09:00:00”,“ScheduleDate”:“2015-12-17”,“ScheduleTime”:“09:00:00”,“endDate”:“许可证结束日期”,“结束时间”:“许可证结束时间”,“测试ID”:2190,“测试代码”:“P15 CP FLT 59”,“测试名称”:“Amazon-2”,“测试类型”:“FLT”,“测试模式”:“ibps”,“testDurationInMinutes”:120,“numberOfQuestions”:104,“访问”:“否”,“状态”:“开始”,“测试结果”:null,“标记”:null},{“activatedDate”:null,“activatedTime”:null,“ScheduleDate”:null,“ScheduleTime”:null,”endDate:null,“endTime:null”,testId:2192,“testCode”:“P15 CP FLT 60”,“testName”:“Amazon-3”,“testType”:“FLT”,“testPattern”:“ibps”,“testDurationInMinutes”:120,“numberOfQuestions”:104,“access”:“No”,“status”:“start”,“testResult”:null,“tags”:null},{“activatedDate”:null,“activatedTime”:null,“ScheduleDate”:null,“ScheduleTime”:null,“endDate”:null,”endTime:null,“testId”:1929,“testCode”:“P15 CP FLT 09”,“testName”:“CapGemini-1”,“testType”:“FLT”,“testPattern”:“ibps”,“testDurationInMinutes”:60,“numberOfQuestions”:75,“access”:“No”,“status”:“start”,“testResult”:null,“tags”:null},{“test ready”:“No”,“reason\u student\u side”:“此测试将于2016年12月22日提供”,“reason\u admin\u side”:“testId”“:2633,“测试代码”:“BP FLT 87”,“测试名称”:“SBI专家官员测试-5”,“测试类型”:“FLT”,“测试模式”:“ibps”,“测试持续时间分钟”:90,“numberOfQuestions”:120,“访问”:“否”,“状态”:“开始”,“测试结果”:null,“标记”:null}]]
[{“tagId”:196,“tag”:“IBPS文书预备课”,“测试次数”:1,“测试”:[{“testId”:2193,“testCode”:“P15 CP FLT 61”,“testName”:“Amazon-4”,“testType”:“FLT”,“testPattern”:“IBPS”,“testDurationInMinutes”:120,“numberOfQuestions”:104,“access”:“No”,“status”:“start”,“testResult”:null,“tags”:[“2017”,“IBPS文书预备课”],“activatedDate”:null,“activatedTime”:null,“endDate”:null,“endTime”:null,“scheduleDate”:null,“scheduleTime”:null}},{“tagId”:0,“tag”:“其他”,“测试次数”:6,“测试”:[{“testId”:2525,“testCode”:“CP 16 FLT 04”,“testName”:“Tech Mahindra-4”,“testType”:“FLT”,“testPattern”:“ibps”,“testDurationInMinutes”:65,“numberOfQuestions”:76,“access”:“No”,“status”:“start”testResult:null,“tags:null,”activatedDate:null,“activatedTime:null,”endDate:null,“scheduleDate:null”,scheduleDate:null},{“testId”:2188,“testCode”:“P15 CP FLT 58”,“testName”:“Amazon-1”,“testType”:“FLT”,“testPattern”:“ibps”,“testdurationofminutes”:120,“numberquestions”:104,“access”:“No”,“status”:“Resume”,“testResult”:null,”标签:null,“activatedDate”:“2015-12-17”,“activatedTime”:“09:00:00”,“endDate”:“许可证结束日期”,“endTime”:“许可证结束时间”,“scheduleDate”:“2015-12-17”,“scheduleTime”:“09:00:00”},{“testId”:2190,“testCode”:“P15 CP FLT 59”,“testName”:“Amazon-2”,“testType”:“FLT”,“testPattern”:“ibps”,“TestDurationnMinutes”:120,“numberOfQuestions”:104,“access”:“No”状态:“开始”,“测试结果”:null,“标记”:null,“激活日期”:“2015-12-17”,“激活日期”:“09:00:00”,“结束日期”:“许可证结束日期”,“结束时间”:“许可证结束时间”,“日程日期”:“2015-12-17”,“日程时间”:“09:00:00”},{“testId”:2192,“测试代码”:“P15 CP FLT”