Search code examples
jsonscalajacksongatling

Gatling's jsonPath silently converts null object to "null" String


I'm currently evaluating gatling 3.3.1 for a use-case and need to retrieve JSON data from a server, manipulate it and send it back. Unfortunately, I've hit an interesting road block with null values in the response.

I'm using Jackson's ObjectMapper to deserialize and serialize the value to a HashMap[Object,Any]:

scenario("scenario")
  .exec(http("get")
    .get(url)
    .asJson
    .check(jsonPath("$").saveAs("json")))
  .exec(http("post")
    .post(url)
    .asJson
    .body(StringBody("${json}")))

Here's a website dummy to try it out: https://webhook.site/7130d3d3-ddcc-4c36-8864-c3a6c4c13cf4

The webserver returns:

{
  "name": "frodo",
  "note": null
}

The gatling script echos back:

{
  "name": "frodo",
  "note": "null"
}

You see, the note field became "null" instead of the correct null. Why is this happening? Is there a way around it? Am I doing something wrong? Some Jackson option I'm missing?


Solution

  • That's a bug that will be fixed in the next release (3.4.0). Thanks for reporting but next time, could you please use our bugtracker on Github? :)