1

This is my request body in java, I am getting this from POJO.

I've used @JsonInclude(value = JsonInclude.Include.NON_NULL) in phonenumber, country, email, addresses class. But It is not removing the node.

How can I remove phonenumber, country, email, addresses nodes/arrays?

{
    "phoneNumbers": [
        {
            
        }
    ],
    "country": {
        
    },
    "addresses": [
        {
            
        }
    ],
    "email": [
        {
            "type": "primary",
            "value": "testHbFhO@mail7.io"
        }
    ],
    "password": "p@s$w0rD"
}

I want my request body to be sent as below:

{
   "email": [
        {
            "type": "primary",
            "value": "testHbFhO@mail7.io"
        }
    ],
    "password": "p@s$w0rD"
}

This would be a dynamic POST request, so I am looking for a dynamic solution, do not want to hardcode the phonenumber, country etc nodes.

happy songs
  • 835
  • 8
  • 21
  • Maybe this is helpful: https://stackoverflow.com/questions/23101260/ignore-fields-from-java-object-dynamically-while-sending-as-json-from-spring-mvc – happy songs Jun 21 '22 at 12:04

0 Answers0