Reputation: 815
I am trying to get familiar with Java and Spring Boot and I have managed to set up a service and a controller as I needed but there is one minor issue I can not seem to solve.
The Get Mapping should return a List of Classes from a 3rd party library, which it does. The Issue is that it is not including the property names in the JSON response.
@GetMapping("/{symbol}/{timeframe}")
public List<Candlestick> getOHLCV(@PathVariable("symbol") String symbol,
@PathVariable("timeframe") String timeframe) {
return service.getOHLCV(symbol, IntervalConverter.fromString(timeframe));
}
The Candlestick Class holds properties like open, high,low,close but these property names are all missing in the response. Why is that the case and how to solve that?
I get a response array like this:
[[1675190700000,"23143.08000000","23179.36000000","23141.26000000","23178.22000000","766.15847000",1675190999999,"17746710.34454660",22165,"453.83717000","10512390.22459520"]]
Upvotes: 0
Views: 723
Reputation: 110
Try adding @JsonProperty on property name
public class Candlestick {
@JsonProperty("open")
private String open;
@JsonProperty("high")
private String high;
@JsonProperty("low")
private String low;
@JsonProperty("close")
private String close;
// getters and setters
}
Upvotes: 1