I have the following JSON from a response from a random REST request:
{ pages= { 56206384={ title = Siberia } }
how can I extract the element "title", given that the number 56206384 will change with every new request? is there a way to have a regex expression for any number?
already tried: def title = ParsedResponse.query.pages.(*).title
any ideas? would appreciate the help
{ pages= { 56206384={ title = Siberia } }
how can I extract the element "title", given that the number 56206384 will change with every new request?
If you know the structure will be just like what you have shown, you could do something like this.
import groovy.json.JsonSlurper
def slurper = new JsonSlurper()
def json = slurper.parseText '{ "pages": { "56206384" : { "title": "Siberia" } }'
def title = json.pages.values().title[0]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.