Groovy web console

subscribe to the feed Subscribe
to this

Find and collect

Published 3 months ago by mrhaki
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.json.*
def jsonText = '{"values": [{"name": "Willem"}, {"name": "mrhaki"}]'
def json = new JsonSlurper().parseText(jsonText)

def allWillems = json.values.findAll { value -> "Willem" == }.collect { value-> }

println allWillems

def singleW = json.values.find { value ->"W") }.name

println singleW