Array of JSON Object to Java POJO

前端 未结 3 2081
情歌与酒
情歌与酒 2020-11-22 09:49

Converting this JSON object as a class in java, how would the mapping be in your POJO Class?

{
    \"ownerName\": \"Robert\",
    \"pets\": [
        {
             


        
3条回答
  •  一向
    一向 (楼主)
    2020-11-22 10:38

    In the above json you have ownerName as property, pets as List of objects

    public class Response {
    
      private String ownerName;
    
      private List pets;
    
      // getters and setters
      }
    

    Pet POJO

    public class Pet {
    
     private String name;
    
     //getters and setters
    
      }
    

提交回复
热议问题