On Tue, Oct 30, 2018 at 10:32 PM Yuriy Barvenko <[email protected]> wrote:
>
>
> 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?

I know there are a few challenges with using Lombok, but since I do
not use it myself I don't know exact details.
For what it is worth, some other frameworks (auto-values, immutables)
tend to have less problems as they handle code generation bit
differently from Lombok.

But one thing I would make sure is to use latest Jackson databind
module (2.9.7 if possible) first.
And after that if things still are not working, probably search for
"jackson lombok constructor" or something -- I think there are many
blogposts and SO matches that outline workarounds.

-+ Tatu +-

-- 
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.

Reply via email to