//source: https://gist.github.com/2478499 def tree = { [:].withDefault{ owner.call() } } // ta-da! users = tree() users.harold.username = 'hrldcpr' users.yates.username = 'tim' users.with { al.username = 'al1' derek.username = 'skinnyk1d' frier.with { username = 'great1' password = 'changeme1' updatedOn = '4/26/2012' } bob.with { age = 4 isOld = false } } println new groovy.json.JsonBuilder( users ).toPrettyString()
No comments:
Post a Comment