简体   繁体   English

从对象的对象创建Json对象模板

[英]Creating Json Object Template From Objects Of Objects

I have one JSON which looks something like this 我有一个看起来像这样的JSON

{  
   "uniqueId":"junk",
   "buildingId":"123",
   "famousFor":[  
      {  
         "famousForId":"asd",
         "name":"Gaming",
         "activeState":true
      }
   ],
   "openHours":[  
      {  
         "day":"Sunday",
         "timingsFrom":{  
            "time":"11:00",
            "meridian":"AM"
         },
         "timingsTo":{  
            "time":"11:59",
            "meridian":"PM"
         }
      }
   ],
   "uploadedImages":{  
      "coverPhoto":[  
         {  
            "imageUrl":"http://google.com/images/a123a.png",
            "activeState":false
         }
      ],
      "profilePhoto":[  
         {  
            "imageUrl":"http://google.com/images/a123a.png, 
                        "            activeState":false
         }
      ]
   },
   "fDescriptions":[  
      {  
         "fMapUrl":"http://google.com/images/a123a.png",
         "tag":"1"
      }
   ],
   "Outlets":[  
      {  
         "outletName":"Halo",
         "floorNumber":1,
         "category":"Gaming"
      }
   ]
}

Now the thing is I have to create one GET API which essentially will provide me the same template with empty value. 现在,我必须创建一个GET API,该API本质上将为我提供具有空值的相同模板。 While returning the Object it's sending me the null value. 返回对象时,它向我发送了空值。 How can I standardized the template that looks the same. 如何标准化外观相同的模板。 My Object looks something like this. 我的对象看起来像这样。

public class EssentialDetails {

    @NotBlank(message=ApplicationUtil.MISSING_FIELD)
    @Valid
    @Pattern(regexp = "[0-9]+$",message="DP ID Must be Number")
    String dpId;
    @Id @NotBlank(message= ApplicationUtil.MISSING_FIELD)
    @Valid
    @Pattern(regexp = "[A-Za-z0-9]+$",message="Must Be Combination of Number and Letters")
    String tpId;
    @NotNull(message=ApplicationUtil.MISSING_FIELD)   @Valid
    List<FamousFor> famousFor;
    @NotNull(message=ApplicationUtil.MISSING_FIELD)  @Valid
    List<OpenHours> openHours;
    @NotNull(message=ApplicationUtil.MISSING_FIELD)  @Valid
    Pictures uploadedImages;
    @NotNull(message=ApplicationUtil.MISSING_FIELD) @Valid
    List<FloorDescription> floorDescriptions;
    @NotNull(message=ApplicationUtil.MISSING_FIELD)  @Valid
    List<Outlets> mallOutlets;

}

How can I pass the empty template with every field present within the template? 如何在模板中存在每个字段的情况下传递空模板? I'm using java 8 and spring boot 2.0.6. 我正在使用Java 8和Spring Boot 2.0.6。

如果为空或为空,或者注释下方的某些有效值可以在模型的属性上方使用

@JsonInclude(ALWAYS)

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

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