Difference between revisions of "EclipseLink/Examples/MOXy/JSON Twitter"

From Eclipsepedia

Jump to: navigation, search
(New page: <div style="margin:5px;float:right;border:1px solid #000000;padding:5px">__TOC__</div> =JSON Binding and Twitter= In this example our JSON corresponds to the results of a query to get r...)
 
Line 4: Line 4:
  
 
In this example our JSON corresponds to the results of a query to get recent tweets about JAXB.  We will use the [https://dev.twitter.com/docs/api/1/get/search Twitter Search API] for this.
 
In this example our JSON corresponds to the results of a query to get recent tweets about JAXB.  We will use the [https://dev.twitter.com/docs/api/1/get/search Twitter Search API] for this.
 +
 +
==Twitter Query==
 +
 +
Below is the URL corresponding to the search.  We are looking for posts containing the word "jaxb", and want the result returned as JSON:
 +
 +
http://search.twitter.com/search.json?q=jaxb
 +
 +
==JSON Result==
 +
 +
Below is an example of the JSON returned from Twitter:
 +
 +
<div style="width:850px">
 +
<source lang="text">
 +
{
 +
  "completed_in":0.153,
 +
  "max_id":101941099769245696,
 +
  "max_id_str":"101941099769245696",
 +
  "next_page":"?page=2&max_id=101941099769245696&q=jaxb",
 +
  "page":1,
 +
  "query":"jaxb",
 +
  "refresh_url":"?since_id=101941099769245696&q=jaxb",
 +
  "results":[
 +
      {
 +
        "created_at":"Fri, 12 Aug 2011 09:00:26 +0000",
 +
        "from_user":"44aki110",
 +
        "from_user_id":92669210,
 +
        "from_user_id_str":"92669210",
 +
        "geo":null,
 +
        "id":101941099769245696,
 +
        "id_str":"101941099769245696",
 +
        "iso_language_code":"ja",
 +
        "metadata":{
 +
            "result_type":"recent"
 +
        },
 +
        "profile_image_url":"http://a2.twimg.com/profile_images/1301749249/44aki110_normal.jpg",
 +
        "source":"<a href="http://www.soicha.com" rel="nofollow">SOICHA</a>",
 +
        "text":"How do you pronounce JAXB?: You know, must suchlike acronyms have alternative pronunciations. URL is pronounced ... http://bit.ly/qsJfHJ",
 +
                  "to_user_id":null,
 +
        "to_user_id_str":null
 +
      },
 +
      {
 +
        "created_at":"Fri, 12 Aug 2011 01:14:57 +0000",
 +
        "from_user":"stackfeed",
 +
        "from_user_id":212341639,
 +
        "from_user_id_str":"212341639",
 +
        "geo":null,
 +
        "id":101823955765170176,
 +
        "id_str":"101823955765170176",
 +
        "iso_language_code":"en",
 +
        "metadata":{
 +
            "result_type":"recent"
 +
        },
 +
        "profile_image_url":"http://a2.twimg.com/sticky/default_profile_images/default_profile_3_normal.png",
 +
        "source":"<a href="http://twitterfeed.com" rel="nofollow">twitterfeed</a>",
 +
        "text":"How to customise the XML output of a Jersey JAXB serialisation: I have some @javax.xml.bind.annotation.Xml... an... http://bit.ly/ogK4Xg",
 +
        "to_user_id":null,
 +
        "to_user_id_str":null
 +
      },
 +
 +
</source>
 +
</div>

Revision as of 16:33, 15 June 2012

JSON Binding and Twitter

In this example our JSON corresponds to the results of a query to get recent tweets about JAXB. We will use the Twitter Search API for this.

Twitter Query

Below is the URL corresponding to the search. We are looking for posts containing the word "jaxb", and want the result returned as JSON:

http://search.twitter.com/search.json?q=jaxb

JSON Result

Below is an example of the JSON returned from Twitter:

{
   "completed_in":0.153,
   "max_id":101941099769245696,
   "max_id_str":"101941099769245696",
   "next_page":"?page=2&max_id=101941099769245696&q=jaxb",
   "page":1,
   "query":"jaxb",
   "refresh_url":"?since_id=101941099769245696&q=jaxb",
   "results":[
      {
         "created_at":"Fri, 12 Aug 2011 09:00:26 +0000",
         "from_user":"44aki110",
         "from_user_id":92669210,
         "from_user_id_str":"92669210",
         "geo":null,
         "id":101941099769245696,
         "id_str":"101941099769245696",
         "iso_language_code":"ja",
         "metadata":{
            "result_type":"recent"
         },
         "profile_image_url":"http://a2.twimg.com/profile_images/1301749249/44aki110_normal.jpg",
         "source":"<a href="http://www.soicha.com" rel="nofollow">SOICHA</a>",
         "text":"How do you pronounce JAXB?: You know, must suchlike acronyms have alternative pronunciations. URL is pronounced ... http://bit.ly/qsJfHJ",
                  "to_user_id":null,
         "to_user_id_str":null
      },
      {
         "created_at":"Fri, 12 Aug 2011 01:14:57 +0000",
         "from_user":"stackfeed",
         "from_user_id":212341639,
         "from_user_id_str":"212341639",
         "geo":null,
         "id":101823955765170176,
         "id_str":"101823955765170176",
         "iso_language_code":"en",
         "metadata":{
            "result_type":"recent"
         },
         "profile_image_url":"http://a2.twimg.com/sticky/default_profile_images/default_profile_3_normal.png",
         "source":"<a href="http://twitterfeed.com" rel="nofollow">twitterfeed</a>",
         "text":"How to customise the XML output of a Jersey JAXB serialisation: I have some @javax.xml.bind.annotation.Xml... an... http://bit.ly/ogK4Xg",
         "to_user_id":null,
         "to_user_id_str":null
      },