Groovy web console

subscribe to the feed Subscribe
to this
site
a (via #groovywebconsole)
tweet this snippet Tweet
this
script

a

Published 7 months ago by a with tags a
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.json.JsonBuilder
import groovy.json.JsonOutput

def parseJSON(json) {
    //return new groovy.json.JsonSlurperClassic().parseText(json)
    return new groovy.json.JsonSlurper().parseText(json)
}

def body = JsonOutput.toJson(["j4device":"", "cache":"", "changes":""])

def cache_id = "123"
def j4device = "1000/1"
def gerrit_changes = """
{ "name":"j4media_git", "pn":"j4media", "type":"repo", "change":{"libj4media":"3639/1", "j4media":"3647/1", "libjacqaudio":"3654/1" } }
{ "name":"gst-jacq-alaw", "pn":"gst-jacq-alaw", "type":"git","change":"3650/2"}"""
def result = parseJSON(body)


//result << [legs:"123456"]

result.j4device = j4device
result.cache = cache_id
gerrit_json = JsonOutput.toJson(parseJSON(JsonOutput.prettyPrint(gerrit_changes)))
//gerrit_json2 = JsonOutput.toJson(gerrit_json)
//println(gerrit_json)
//println(JsonOutput.prettyPrint(gerrit_changes))

//println(gerrit_json)

result.changes = gerrit_json

println(result)