The Groovy development team is pleased to announce the joint release of Groovy 1.7.7 and Groovy 1.8-beta-4, the latest releases of the popular dynamic language for the JVM.
Groovy 1.7.7 is a maintenance release of our official stable 1.7.x branch, whereas 1.8-beta-4 is the last beta version before the release candidates of the upcoming major version of Groovy.
The key highlights of the latest beta are:
If you wish to learn more about the JSON support, you can have a look at the JSON Groovy Extension Proposal and the unit tests for the slurper and the builder.
Here's an example for the JSON slurper, fetching tweets from Twitter about the #groovy hashtag:
import groovy.json.*
def slurper = new JsonSlurper()
def url = "http://search.twitter.com/search.json?q=%23groovy"
def content = new URL(url).getText("UTF-8")
def root = slurper.parseText(content)
root.results.each { println it.text }
|
And another example showing how you can create JSON payloads with the JSON builder:
import groovy.json.*
def json = new JsonBuilder()
json.response {
status "ok"
userTier "free"
total 2413
startIndex 1
pageSize 10
currentPage 1
pages 242
orderBy "newest"
results([
id: "world/video/2011/jan/19/tunisia-demonstrators-democracy-video",
sectionId: "world",
sectionName: "World news",
webPublicationDate: "2011-01-19T15:12:46Z",
webTitle: "Tunisian demonstrators demand new democracy - video",
webUrl: "http://www.guardian.co.uk/world/video/2011/jan/19/tunisia-demonstrators-democracy-video",
apiUrl: "http://content.guardianapis.com/world/video/2011/jan/19/tunisia-demonstrators-democracy-video"
],
[
id: "world/gallery/2011/jan/19/tunisia-protests-pictures",
sectionId: "world",
sectionName: "World news",
webPublicationDate: "2011-01-19T15:01:09Z",
webTitle: "Tunisia protests continue - in pictures ",
webUrl: "http://www.guardian.co.uk/world/gallery/2011/jan/19/tunisia-protests-pictures",
apiUrl: "http://content.guardianapis.com/world/gallery/2011/jan/19/tunisia-protests-pictures"
])
}
|
You can download and read about the JIRA release notes here:
Groovy 1.7.7
Groovy 1.8-beta-4
You may wish to have a look at the recent features introduced in previous betas by reading the following release notes:
Thanks a lot to all involved in this pair of releases, and for the support of our friendly community!