Groovy web console

subscribe to the feed Subscribe
to this
site

json

Published 3 weeks ago by mk
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def message = '''This is supposed to contain some "double quotes"
                    and line breaks.'''

text = new groovy.json.JsonBuilder(message).toString()
println(text)

def msg = new groovy.json.JsonSlurperClassic().parseText """
{ "text": ${text},
  "title": "foo",
  "themeColor": "bar"
}
"""

println(msg)