subhaD
6 years agoContributor
Groovy If loop example
I am new to groovy scripting, am trying to loop through the rest response in below format
"addressData" : [ { "type" : "MAILING", "address" : { ...
- 6 years ago
Provided JSON is not correct. Here is the basic example how you can traverse through JSON:-
import groovy.json.JsonSlurper def json = '''{"books":{"science":"biology", "commerce": "accountancy"}}''' jSlurper = new JsonSlurper().parseText(json) log.info (jSlurper.books.commerce);
This way if you have arrays of JSON, in that case you should use Using Gson .