Remove empty json field in Component Expoter

39 Views Asked by At

How to exclude Json tab field when it has no value being authored in component dialog field (Sling model)?

dialog

  • a (authored value) tab
  • b (not authored) tab

json response with model.json of experience fragment

"Component" : {
   "a":{
         "field":"authored value"

       },
   "b": {
         "field": null
        }
}

I am expecting to be removed from json response if it is not authored.

"Component" : {
   "a":{
         "field":"authored value"
       }
  }
1

There are 1 best solutions below

0
Alexander Berndt On

You can use all Jackson Annotations (com.fasterxml.jackson.annotation) to modify JSON output. In your case:

@JsonInclude(JsonInclude.Include.NON_NULL)
public String getA() {....}