Home How to retrieve Arraylist/list from json rest request and convert into pojo object (one of pojo variable is of list type.)
Reply: 0

How to retrieve Arraylist/list from json rest request and convert into pojo object (one of pojo variable is of list type.)

user1074
1#
user1074 Published in April 23, 2018, 9:34 am

How to retrieve ArrayList/List from JSON REST request and convert into POJO object (one of POJO variable is of list type).

// Domain class

@Service
@JsonIgnoreProperties(ignoreUnknown = true)
public class DocumentProps {

    @JsonProperty("name")
    private String name;

    @JsonProperty("type")
    private String type;

    @JsonProperty("properties")  // list variable
    private List properties;

// controller-class

@RestController
public class springteamplate {

@Autowired
    DocumentProps docprops;

@GetMapping(value = "/get")
    private  void getEmployees()
    {
        final String uri = "http://xyz";        
        docprops = RestTemplateBuild.template.getForObject(uri, DocumentProps.class);
        System.out.println(docprops.getName()); // able to retrieve name
        System.out.println(docprops.getType());  // able to retrieve type
        System.out.println(docprops.getPrpopertie());  // How to retrieve list of properties.
    }}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.469201 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO