I am facing a problem with formatting JSON as response data. I have a class Player, which has the fields name, id, age, top, middle, and bottom. I have another class Position which has fields id, top, middle, and bottom. Player fields top, middle, and bottom come from Position and set it for Player.
My problem is I am getting JSON response data as:
{ id : 10,
age : 16,
top : 18,
middle : 16,
bottom : 10
}
Whereas I want it as:
{ id : 10,
age : 16,
position : {
top : 18,
middle : 16,
bottom : 10
}
}