0

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

1 Answer 1

1

{ 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]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.