001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.examples.core.dto.atom;
014
015import org.apache.juneau.dto.atom.Feed;
016import org.apache.juneau.json.JsonSerializer;
017import org.apache.juneau.json.Json5Serializer;
018
019/**
020 * Atom feed JSON example.
021 *
022 * <h5 class='section'>See Also:</h5><ul>
023 * </ul>
024 */
025public class AtomJsonExample {
026
027   /**
028    * JSON Atom feed example.
029    *
030    * @param args Unused.
031    * @throws Exception Unused.
032    */
033   @SuppressWarnings("unused")
034   public static void main(String[] args) throws Exception {
035
036      Feed feed = AtomFeed.getAtomFeed();
037
038      // Get JSON serializer with readable output.
039      JsonSerializer s = Json5Serializer.DEFAULT_READABLE;
040
041      // Serialize to ATOM/JSON
042      //Produces
043      /**
044       * {
045       *  id: {
046       *      text: 'tag:juneau.apache.org'
047       *  },
048       *  links: [
049       *      {
050       *          href: 'http://juneau.apache.org/',
051       *          rel: 'alternate',
052       *          type: 'text/html',
053       *          hreflang: 'en'
054       *      },
055       *      {
056       *          href: 'http://juneau.apache.org/juneau.atom',
057       *          rel: 'self',
058       *          type: 'application/atom+xml'
059       *      }
060       *  ],
061       *  title: {
062       *      type: 'text',
063       *      text: 'Juneau ATOM specification'
064       *  },
065       *  updated: '2016-01-02T03:04:05Z',
066       *  generator: {
067       *      uri: 'http://juneau.apache.org/',
068       *      version: '1.0',
069       *      text: 'Juneau'
070       *  },
071       *  subtitle: {
072       *      type: 'html',
073       *      text: 'Describes <em>stuff</em> about Juneau'
074       *  },
075       *  entries: [
076       *      {
077       *          authors: [
078       *              {
079       *                  name: 'James Bognar',
080       *                  uri: 'http://juneau.apache.org/',
081       *                  email: 'jamesbognar@apache.org'
082       *              }
083       *          ],
084       *  contributors: [
085       *      {
086       *          name: 'Barry M. Caceres'
087       *      }
088       *  ],
089       *  id: {
090       *      text: 'tag:juneau.apache.org'
091       *  },
092       *  links: [
093       *      {
094       *          href: 'http://juneau.apache.org/juneau.atom',
095       *          rel: 'alternate',
096       *          type: 'text/html'
097       *      },
098       *      {
099       *          href: 'http://juneau.apache.org/audio/juneau_podcast.mp3',
100       *          rel: 'enclosure',
101       *          type: 'audio/mpeg',
102       *          length: 12345
103       *      }
104       *  ],
105       *  title: {
106       *      text: 'Juneau ATOM specification snapshot'
107       *  },
108       *  updated: '2016-01-02T03:04:05Z',
109       *  content: {
110       *      base: 'http://www.apache.org/',
111       *      lang: 'en',
112       *      type: 'xhtml',
113       *      text: '<div xmlns="http://www.w3.org/1999/xhtml"><p><i>[Update: Juneau supports ATOM.]</i></p></div>'
114       *  },
115       *  published: '2016-01-02T03:04:05Z'
116       *  }
117       *  ]
118       *  }
119       */
120      String atomJson = s.serialize(feed);
121   }
122}