Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Strange jsonpath not able to capture (Gatling/Scala)

I have a responsebody that looks like this:

[
  {
    "system": "http://snomed.info/sct",
    "code": "735938006",
    "display": "akutt hodepine"
  },
  {
    "system": "http://snomed.info/sct",
    "code": "267096005",
    "display": "frontal hodepine"
  },
  {
    "system": "http://snomed.info/sct",
    "code": "103011009",
    "display": "godartet anstrengelseshodepine"
  },
  {
    "system": "http://snomed.info/sct",
    "code": "25064002",
    "display": "hodepine"
  },
  {
    "system": "http://snomed.info/sct",
    "code": "38823002",
    "display": "hodepine med aura"
  },
  {
    "system": "http://snomed.info/sct",
    "code": "193031009",
    "display": "klasehodepine"
  },
  {
    "system": "http://snomed.info/sct",
    "code": "230465000",
    "display": "migrene med aura uten hodepine"
  },
  {
    "system": "http://snomed.info/sct",
    "code": "330007",
    "display": "oksipital hodepine"
  },
  {
    "system": "http://snomed.info/sct",
    "code": "54012000",
    "display": "posttraumatisk hodepine"
  },
  {
    "system": "http://snomed.info/sct",
    "code": "4969004",
    "display": "sinushodepine"
  },
  {
    "system": "http://snomed.info/sct",
    "code": "398057008",
    "display": "tensjonshodepine"
  },
  {
    "system": "http://snomed.info/sct",
    "code": "128187005",
    "display": "vaskulær hodepine"
  }
]

and I want to capture the value "hodepine" element 3 from the top. I use IntelliJ and "Copy JSON Pointer" and it gives me this:

/3/display

This does not work using it in Gatling/Scala like this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

.check(jsonPath("$../3/display").saveAs("display"))

The error is:

> jsonPath($../3/display).find.exists, found nothing 

Any tips on how to obtain the value?

>Solution :

I have the answer on similar question and it can be helpful for you.

For your case: $.[3].display

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading