jsonpath extract value from REQUEST string (not response body)


How to use jsonpath to extract value from JSON request body (Note, not the response body).

Say I have a JSON string, not the response body, such as:

val jsonStr = “”"

{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}

How to use jsonpath to extract field "id" to get value "file" in Gatling?

Can I use the build-in Gatling jsonPath, how to use it?

Or is there a way or sample code to use third-party jsonpath library using scala?



Doubt you can use built-in Gatling jsonpath because that’s part of check - which you use on responses.

Should be simple to extract using Scala - a quick search found this page with information on some json libraries for Scala - http://json4s.org/ (and of course you have Java json libraries at your disposal)