Skip to content

Instantly share code, notes, and snippets.

@rupzme
Created October 19, 2015 14:25
Show Gist options
  • Save rupzme/c579635791b6035eed72 to your computer and use it in GitHub Desktop.
Save rupzme/c579635791b6035eed72 to your computer and use it in GitHub Desktop.
SoapUI JSONPath Groovy Script Example Example
import static com.jayway.jsonpath.JsonPath.parse
def json = '''{"quote": {
"id": 12345,
"am ount": 100,
"links": [
{
"rel": "self",
"href": "http://localhost:8080/quote/777"
},
{
"rel": "customer",
"href": "http://localhost:8080/customer/12345"
}
]
}}
}'''
log.info parse(json).read('$.quote.id')
log.info parse(json).read('$.quote.am ount')
log.info parse(json).read('$.quote.links[0].href')
def quoteId = parse(json).read('$.quote.id')
log.info quoteId
assert quoteId==12345
assert parse(json).read('$.quote.id')==12345
@naXa777
Copy link

naXa777 commented Oct 5, 2017

@susnigdha1 com.jayway.jsonpath (jsonpath-jar-2.4.0) placed in 'bin/ext' directory of SoapUI works for me. You probably need to restart SoapUI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment