How to ignore fields and properties while deserializing the JSON response.

2,329 views
Skip to first unread message

Manju Ghargi

unread,
Dec 2, 2015, 8:26:01 AM12/2/15
to REST assured
When I'm trying to map the response received from service call to the respective class during deserialization. I'm getting this error.

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "errors" (class  com.platform.access.types.W2S), not marked as ignorable (2 known properties: "error", "w2Entity"])

How do I specify here to ignore the fields while deserializing the response?
Any help in this regard is appreciated.


Johan Haleby

unread,
Dec 3, 2015, 2:26:35 AM12/3/15
to rest-a...@googlegroups.com
This depends on what serialization framework you're using so I don't think it has much to do with REST Assured. You can configure the serialization frameworks using the this approach if needed. It looks like you're using faster jackson so in your case you can just use an annotation (use google!).

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jason.h...@clearcapital.com

unread,
Mar 7, 2019, 4:21:13 AM3/7/19
to REST assured
    RestAssured.config = RestAssuredConfig.config().objectMapperConfig(new ObjectMapperConfig().jackson2ObjectMapperFactory(
        new Jackson2ObjectMapperFactory() {
          @Override
          public ObjectMapper create(Type cls, String charset) {
            ObjectMapper om = new ObjectMapper().findAndRegisterModules();
            om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            return om;
          }          
          
        }
    ));
Reply all
Reply to author
Forward
0 new messages