Created
November 5, 2011 11:33
-
-
Save toby55kij/1341415 to your computer and use it in GitHub Desktop.
groovy.json.JsonSlurperのサンプル
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
//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