Groovy web console

subscribe to the feed Subscribe
to this
site

Groovy

Published 3 months ago by Smit with tags list map for
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.json.JsonOutput  

def l1 = [];

def map1 = [["name": "smit", "age": "23"], ["name": "avi", age: "12"]];

for(item in map1) {
    item.put("sur_name", "mehta");
    l1.add(item);
}

println(l1);
def output = JsonOutput.toJson(l1);
println(output);