'Common object in two objects java

I am implementing one api and I have the following request bodies for 2 different endpoints:

endpoint1:

 {
  "requests": [
    {
      "id": "123"
    }
  ]
}

endpoint2:

{
  "requests": [
    {
      "variable": "stack"
    }
  ]
}

Is there a way to build a common object for these 2 in java spring application?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source