0

below is my json response and am trying to parse it using Scala in a Gatling script and the value of x is not returned. Can you see what may be the mistake --

[
  [
    {
      "x": "2018-01-23",
      "y": "test"
    },
    {
      "x": "2018-02-02",
      "y": "test1"
    }
]
]

.check(jsonPath(path="$.[0].['x']").is(expected="2018-10-23")))

The error I get is - preparation crashed:       1 (100.0%)
Jackson failed to parse into a valid AST: c.f.j.c.JsonParseExc...
55s25
  • 11
  • 2

2 Answers2

0

This error means the response was not well formed JSON. It could be malformed JSON or not JSON at all (typically HTML). Check logback.xml and lower logging level to check what the response body actually was.

Stéphane LANDELLE
  • 6,076
  • 2
  • 10
  • 12
  • Thanks Stephane for the quick response! Yes, the response was not in JSON format as I was getting re-directed back to login page, due to authentication failure. – 55s25 Aug 10 '20 at 16:02
0

I got this fixed by setting the request headers: Accept & Content-Type to application/json. Like so:

Map.entry("Accept", "application/json"), 
Map.entry("Content-Type", "application/json"),
Alferd Nobel
  • 3,185
  • 2
  • 30
  • 35