Skip to content

Instantly share code, notes, and snippets.

@sureshnath
Last active October 27, 2020 20:00
Show Gist options
  • Save sureshnath/78c65b59be73c3409979b3572c8e5518 to your computer and use it in GitHub Desktop.
Save sureshnath/78c65b59be73c3409979b3572c8e5518 to your computer and use it in GitHub Desktop.
using groovy playground
import groovy.json.JsonSlurper
def jsonSlurper = new JsonSlurper()
def object = jsonSlurper.parseText(
'{"count":20,"teams":[{"id":322,"name":"Hull City FC","shortName":"Hull","squadMarketValue":null,"crestUrl":"http://upload.wikimedia.org/wikipedia/de/a/a9/Hull_City_AFC.svg"},{"id":338,"name":"Leicester City FC","shortName":"Foxes","squadMarketValue":null,"crestUrl":"http://upload.wikimedia.org/wikipedia/en/6/63/Leicester02.png"},{"id":340,"name":"Southampton FC","shortName":"Southampton","squadMarketValue":null,"crestUrl":"http://upload.wikimedia.org/wikipedia/de/c/c9/FC_Southampton.svg"}]}'
)
def allTeamNames = object.teams.name
def namesWithCity = object.teams.findAll {it.name =~ /City/}.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment