Created
November 7, 2015 15:53
-
-
Save mattn/e1fb3df8f47697f68887 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('com.sparkjava:spark-core:2.1') | |
import static spark.Spark.* | |
import groovy.json.JsonBuilder | |
Object.metaClass.asJson = { | |
def builder = new JsonBuilder(delegate); | |
builder.toString() | |
} | |
def map = [:] | |
map['foo'] = 'ハローワールド' | |
map['bar'] = [1, 2, 3] | |
map['boo'] = ['hoge' : 'aaa', 'fuga' : [1, 2, ['obj':true]]] | |
get('/map', { req, res -> map.asJson() }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment