githubraj1 / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

Why parse the content youself? #256

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Currently there is a ContentParser that parses JSON content through 
ConfigurableJsonSlurper. 

Why not to use the Jackson's Parse to do that for you? (through Object Mapper)

Currently there is no way (or I haven't found the way) I can deserialize JSON 
that has unquoted field names ( e.g. {foo : "bar"}) with REST Assured, however 
I can easily do it with new 
ObjectMapper().configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); of Jackson.

Setting configuration should've used my ObjectMapper to deserialize JSON, 
however it is does not.

RestAssured.config = RestAssuredConfig.config().objectMapperConfig(new 
ObjectMapperConfig().jackson2ObjectMapperFactory(
                new Jackson2ObjectMapperFactory() {

                    @Override
                    public ObjectMapper create(Class cls, String charset) {
                        return new ObjectMapper().configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
                    }
                }
        ));

Alex

Original issue reported on code.google.com by alex.okr...@gmail.com on 18 Sep 2013 at 7:15

GoogleCodeExporter commented 8 years ago
Hi, 

The reason is that REST Assured uses GPath to traverse the JSON/XML document. 
This is what enables you to do ".. body("x.y.z", equalTo("w"))" etc. You can't 
do that once you've converted the document to a Java structure afaik (at least 
not as easily).

Regards,
/Johan

Ps, please ask questions on the mailing list in the future. That way I'll see 
them quicker and it seems like the right forum before entering a new ticket. 

Original comment by johan.ha...@gmail.com on 25 Sep 2013 at 5:14