I have both GSON and Jackson in a project using RestAssured and I want to use GSON. The official documentation does not provide a clear example. I tried several configs, but it does not seem to work. Here's my config, am I missing something?
RestAssured.config = RestAssuredConfig.config()
                .decoderConfig(new DecoderConfig("UTF-8"))
                .encoderConfig(new EncoderConfig("UTF-8", "UTF-8"))
                .objectMapperConfig(new ObjectMapperConfig(GSON));
In my project I solved it by wrapping original RestAssured.given method
public static RequestSpecification given() {
    return RestAssured.given()
        .config(RestAssured.config()
            .objectMapperConfig(new ObjectMapperConfig(ObjectMapperType.GSON)));
}
This worked for me in Kotlin:
RestAssured.config = RestAssuredConfig.config().objectMapperConfig(objectMapperConfig().defaultObjectMapperType(ObjectMapperType.GSON))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With