#Endpoint return with Map - Spring Boot
19 messages · Page 1 of 1 (latest)
Hey, @obsidian swallow!
Please remember to /close this post once your question has been answered!
Example of other returns in the same method:
{ "destination": { "id": "100", "balance": 10 } }
By the way, I can't create different endpoints because the business rule don't does not allow. The same endpoint with the same HTTP method should return different objects depending of the input
......... A Map can contain as many objects as you want
Note that with the example given, I don't quite see why you can't return an OriginAndDestination rather than a Map
Yes, but the return is Map<String, Object>, and the case showed is Map<Object, Object>
What do you mean?
Required type: ResponseEntity <Map<String, Object>>
Provided: ResponseEntity <Map<Object, Object>>
Well give a Map<String, Object> rather than something else
But the return is two objects:
{
"origin":
{
"id":"100",
"balance": 0
},
"destination":
{
"id": "300",
"balance": 15
}
}
And there is others return in the same method where is returned a Map<String, Object>
Dude, key, and value
Map<String, Object> means you can put as many objects as you want, each associated with its own String
Clearer?
Ok, I have these two Maps:
Map<String, Object> origin = new HashMap<>();
Map<String, Object> destination = new HashMap<>();
For this object which I'm responding. How can I merge they?
Because I think this is the object:
{
"origin":
{
"id":"100",
"balance": 0
},
"destination":
{
"id": "300",
"balance": 15
}
}
But, what is the key?