Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

User:Rick.barkhouse.oracle.com/Test1

Dynamic JAXB: Flickr Example

This example will demonstrate how to use MOXy's Dynamic JAXB features to work with public JSON and XML feeds, without having to create concrete Java classes.

Getting JSON from Reddit

Reddit provides a public JSON feed using the following URL format:

http://www.reddit.com/r/science/top/.json?sort=top&t=day&limit=5

This will return us the following JSON. For this example, we are only interested in the title and url fields of data/children.

{
  "kind":"Listing",
  "data":{
    "modhash":"qdohhwkxss9091dc13eed91db333b619420a787aa2a39b3982",
    "children":[
      {
        "kind":"t3",
        "data":{
          "domain":"news.mongabay.com",
          "banned_by":null,
          "media_embed":{
 
          },
          "subreddit":"science",
          "selftext_html":null,
          "selftext":"",
          "likes":null,
          "link_flair_text":null,
          "id":"1f5jv3",
          "clicked":false,
          "title":"Plants re-grow after 500 years under the ice",
          "media":null,
          "score":2665,
          "approved_by":null,
          "over_18":false,
          "hidden":false,
          "thumbnail":"",
          "subreddit_id":"t5_mouw",
          "edited":false,
          "link_flair_css_class":null,
          "author_flair_css_class":null,
          "downs":5569,
          "saved":false,
          "is_self":false,
          "permalink":"/r/science/comments/1f5jv3/plants_regrow_after_500_years_under_the_ice/",
          "name":"t3_1f5jv3",
          "created":1369712639.0,
          "url":"http://news.mongabay.com/2013/0527-dimitrova-ice-plants.html",
          "author_flair_text":null,
          "author":"soyuz-capsule",
          "created_utc":1369683839.0,
          "ups":8234,
          "num_comments":178,
          "num_reports":null,
          "distinguished":null
        }
      },
      ...

Back to the top