jeudi 4 novembre 2021

When returning VO as json, how to return excluding null value?

When returning VO as json, how to return excluding null value?

     @RequestMapping("/rbtInfo.do")
     public RobotVO rbtInfo(@RequestParam String rbtId){
         String rbtPower = "ON";
         robot.setRbtPower(rbtPower);
         return robot;

     }

Above is my controller.

And the return value is as follows.

{
     "rbtId": null,
     "rbtPower": "ON",
     "rtspAddr": null,
     "ifrRtspAddr": null,
     "stationPosition": null,
}

In this case, I want to return only rbtPower for which the value exists, but not the rest.

How can I return excluding null data from VO?




Aucun commentaire:

Enregistrer un commentaire