Reputation: 7219
I have a POJO "Problem" object:
import lombok.Data;
@Data
public class Problem {
int capacity;
int weights[];
int values[];
}
Which I am trying to parse in a Rest controller in Spring Boot:
@RequestMapping(value = "/calculate", method = RequestMethod.POST)
public SolutionResponse calculateSolution(@RequestBody Problem problem) {
// problem = Problem(capacity=0, weights=null, values=null) ??
// Goes on ..
}
I am posting the following with cURL:
curl -d '{"problem": {"capacity": 60, "weights": [5, 2, 22], "values": [2, 5, 30]}}' -H "Content-Type: application/json" -X POST http://localhost:8088/endpoint/calculate
Looking into debug mode, it is indeed parsed, but as:
problem = Problem(capacity=0, weights=null, values=null)
So, it's wrong as they should have the values that I posted.
What could be the issue?
Upvotes: 0
Views: 2703
Reputation: 27078
Json you are sending from curl is not correct.
It should be
{"capacity": 60, "weights": [5, 2, 22], "values": [2, 5, 30]}
Upvotes: 1