Skip to content

Instantly share code, notes, and snippets.

@toby55kij
Created November 5, 2011 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toby55kij/1341415 to your computer and use it in GitHub Desktop.
Save toby55kij/1341415 to your computer and use it in GitHub Desktop.
groovy.json.JsonSlurperのサンプル
//JsonSlurperのサンプル
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
//JSON文字列
def text = '''{
"people": {
"person": {
"firstName": "Yasuharu",
"lastName": "Hayami",
"address": {
"city": "Niigata",
"country": "Japan",
"zip": 9501115
},
"married": false,
"conferences": [
"JGGUG",
"JJUG"
]
}
}
}'''
//JSON文字列をJsonSlurperで読み込む
def data = new JsonSlurper().parse(new StringReader(text))
//内容を確認
println JsonOutput.prettyPrint(JsonOutput.toJson(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment