I have a Json array
{
"id":33,
"dataContent":"user1",
"temp":"36"
},
{
"id":33,
"dataContent":"user2",
"temp":"36"
},
{
"id":33,
"dataContent":"user3",
"temp":"39"
},
{
"id":21,
"dataContent":"user4",
"temp":"38"
},
{
"id":22,
"dataContent":"user5",
"temp":"37"
}
that am generating using the code
@PostMapping(value = "/temperature")
public ResponseEntity<?> Temperature(@Valid @RequestBody Activation activation) {
Temperature temperature = new Temperature();
temperature.setCode(activation.getDataContent());
temperature.setDatecreated(new Date());
temperature.setUser_id(activation.getId());
temperature.setTemperature(activation.getTemp());
temperatureRepository.save(temperature);
return ResponseEntity.ok("Temperature Updated");
}
how can I set a check in such a way that the if the temperature is greater than 38 set a json response as not cleared and if it is less than 38 the response returned is cleared.
{
"message":"cleared"
}
question from:
https://stackoverflow.com/questions/65540642/java-get-one-jsonobject-from-a-jsonarray-and-set-json-response 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…