Created
October 19, 2015 14:25
-
-
Save rupzme/c579635791b6035eed72 to your computer and use it in GitHub Desktop.
SoapUI JSONPath Groovy Script Example Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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.