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 |
Hi, I am trying to use com.jayway.jsonpath (jsonpath-jar-2.2.0). I have copied the jar file under 'bin\ext' of Soapui....but it is failing to import classes from it. I also tried after placing it under 'lib' directory, but no luck so far. Could you let me know which version of jsonpath jar did you use and how you added it to Soapui?
@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
This has saved my bottom on a critical situation. Thank you for sharing this !!