Groovy for Domain-specific Languages - Second Edition

(nextflipdebug2) #1

Example DSL – GeeTwitter


[ 116 ]

Running the curl command will display the resulting HTTP response from Twitter.
This will include the HTTP response headers along with the response body in JSON.
The JSON returned is not formatted in a user-readable manner, so it can be hard to
read. A favorite site of mine is http://www.jsbeautifier.org. Cutting and
pasting the JSON file into the Beautify JavaScript or HTML input box will let you
produce properly formatted JSON. The following code is a much simplified version
of one response:


{
"statuses": [
{
"entities": {
"hashtags": [
{
"text": "Groovy",
"indices": [
13,
19
]
}
]
},
"text": "Let's talk #Groovy at GGX 2014",
"metadata": {
"iso_language_code": "en",
"result_type": "recent"
},
"user": {
"name": "Fergal Dearle",
"created_at": "Mon Apr 26 06:01:55 +0000 2010",
},
"followers_count": 70,
"statuses_count": 579,
"friends_count": 110,
}
]
}

The response JSON contains details about the tweet, including details about the user
who tweeted.


http://www.ebook3000.com
Free download pdf