I just forgot to write, that i use a Lombok framework wit @Data for
generate get and set methods
среда, 31 октября 2018 г., 3:26:00 UTC+1 пользователь Yuriy Barvenko
написал:
>
> I am trying to deserialize following JSON
>
>
> {
> "deliverLumpSum": 0.0,
> "faxQId":
> "{\"type\":\"TAKEAWAY\",\"data\":{\"orderId\":\"AWSWD-AWSAW\",\"orderKey\":\"DERS34S32SD\"}}"
> }
>
>
>
> with help of following custome deserializer
>
> public class OrderIdDeserializer extends JsonDeserializer<OrderId> {
>
>
> @Override
> public OrderId deserialize(JsonParser jsonParser,
> DeserializationContext deserializationContext) throws IOException {
> OrderId orderId = jsonParser.readValueAs(OrderId.class);
> return orderId;
> }
> }
>
>
>
> in to following Object-Structure
>
> public class AddInfo {
>
> protected double deliverLumpSum;
>
> @JsonDeserialize( using = OrderIdDeserializer.class)
> public OrderId orderId;
>
> }
>
>
> public class OrderId {
>
> private String type;
> private TakeawayData data;
>
> }
>
>
> public class TakeawayData {
>
> private String orderId;
> private String orderKey;
>
>
> }
>
>
> and i got the following error
>
> com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
> construct instance of `OrderId` (although at least one Creator exists): no
> String-argument constructor/factory method to deserialize from String
> value (
> '{"type":"TAKEAWAY","data":{"orderId":"AWSWD-AWSAW","orderKey":"DERS34S32SD"}}'
> )
>
>
> what do i wrong and how can i solve this problem?
>
> thx
>
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.