Map Nested JSON Objects to Java Classes with Spring RestTemplate

前端 未结 7 1340
南旧
南旧 2021-02-08 12:17

I know this may be simple. However, I just can\'t get it to work.

So I am trying to use Spring RestTemplate to map my JSON data. I have following JSON response from a re

7条回答
  •  鱼传尺愫
    2021-02-08 12:37

    Please use private List data = new AllarList( ); and please provide getters( ) and setters( ) methods in both the classes.

    Put @JsonInclude(Include.NON_EMPTY) above Data class

    Please add below dependencies under section at your main POM.xml file and do maven compile. Then I guess your issue will get resolved.

            
                com.fasterxml.jackson.core
                jackson-annotations
                2.2.3
            
    
            
                com.fasterxml.jackson.core
                jackson-databind
                2.2.3
            
    
            
                com.fasterxml.jackson.datatype
                jackson-datatype-joda
                2.1.1
            
    
            
                org.codehaus.jackson
                jackson-mapper-asl
                1.8.8
            
    

提交回复
热议问题