skip to Main Content

Spring Boot controller to handle invalid JSON

I have a Spring Boot controller that consumes JSON: @PostMapping( value = "/shipdetails") public ResponseEntity acceptShip(@RequestBody Ship ship, HttpServletRequest request) { shipService.checkShip(ship); return new ResponseEntity<>(HttpStatus.OK); } There is a corresponding Ship Entity: public class Ship implements Serializable { @JsonProperty("Name") private…

VIEW QUESTION

Json – Deserialization using jackson mapper annotations in java

I am trying to deserialize the following json using Jackson annotations. Here is my current code: @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "serviceType") @JsonSubTypes({ @JsonSubTypes.Type(value = StripeServiceConfiguration.class, name = "Stripe"), @JsonSubTypes.Type(value = BrainServiceConfiguration.class, name = "Brain"), })…

VIEW QUESTION

Java Json enum deserialization

JSON enum deserialization is not working. Interface: @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property="rlType" ) @JsonSubTypes({ @JsonSubTypes.Type(value = B.class) }) public interface IA { } B class @JsonTypeInfo(use = JsonTypeInfo.Id.NONE) public enum B implements IA { X, Y, Z…

VIEW QUESTION

How to read several Json arrays from input and convert them to Java array or List

I'm receiving an input of one or more Json arrays like [{"operation":"buy", "unit-cost":10.00, "quantity": 10000}, {"operation":"sell", "unit-cost":20.00, "quantity": 5000}] [{"operation":"buy", "unit-cost":20.00, "quantity": 10000}, {"operation":"sell", "unit-cost":10.00, "quantity": 5000}] I tried to read the array using JSON-Java in this way: JSONArray array…

VIEW QUESTION
Back To Top
Search