jsonpath extract value from REQUEST string (not response body)

85 views
Skip to first unread message

Eric Ouyang Z

unread,
Oct 19, 2016, 5:57:37 PM10/19/16
to Gatling User Group
Hi,

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?

Thanks.

Barry Perez

unread,
Oct 20, 2016, 5:14:08 AM10/20/16
to Gatling User Group
Hi,

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)

Cheers,
Barry
Reply all
Reply to author
Forward
0 new messages