001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.examples.bean.atom;
018
019import org.apache.juneau.json.*;
020
021/**
022 * Atom feed JSON example.
023 *
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      var feed = AtomFeed.getAtomFeed();
037
038      // Get JSON serializer with readable output.
039      var 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      var atomJson = s.serialize(feed);
121   }
122}