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.bean.atom.*; 020import org.apache.juneau.json.*; 021 022/** 023 * Atom feed JSON example. 024 * 025 * <h5 class='section'>See Also:</h5><ul> 026 * </ul> 027 */ 028public class AtomJsonExample { 029 030 /** 031 * JSON Atom feed example. 032 * 033 * @param args Unused. 034 * @throws Exception Unused. 035 */ 036 @SuppressWarnings("unused") 037 public static void main(String[] args) throws Exception { 038 039 Feed feed = AtomFeed.getAtomFeed(); 040 041 // Get JSON serializer with readable output. 042 JsonSerializer s = Json5Serializer.DEFAULT_READABLE; 043 044 // Serialize to ATOM/JSON 045 //Produces 046 /** 047 * { 048 * id: { 049 * text: 'tag:juneau.apache.org' 050 * }, 051 * links: [ 052 * { 053 * href: 'http://juneau.apache.org/', 054 * rel: 'alternate', 055 * type: 'text/html', 056 * hreflang: 'en' 057 * }, 058 * { 059 * href: 'http://juneau.apache.org/juneau.atom', 060 * rel: 'self', 061 * type: 'application/atom+xml' 062 * } 063 * ], 064 * title: { 065 * type: 'text', 066 * text: 'Juneau ATOM specification' 067 * }, 068 * updated: '2016-01-02T03:04:05Z', 069 * generator: { 070 * uri: 'http://juneau.apache.org/', 071 * version: '1.0', 072 * text: 'Juneau' 073 * }, 074 * subtitle: { 075 * type: 'html', 076 * text: 'Describes <em>stuff</em> about Juneau' 077 * }, 078 * entries: [ 079 * { 080 * authors: [ 081 * { 082 * name: 'James Bognar', 083 * uri: 'http://juneau.apache.org/', 084 * email: 'jamesbognar@apache.org' 085 * } 086 * ], 087 * contributors: [ 088 * { 089 * name: 'Barry M. Caceres' 090 * } 091 * ], 092 * id: { 093 * text: 'tag:juneau.apache.org' 094 * }, 095 * links: [ 096 * { 097 * href: 'http://juneau.apache.org/juneau.atom', 098 * rel: 'alternate', 099 * type: 'text/html' 100 * }, 101 * { 102 * href: 'http://juneau.apache.org/audio/juneau_podcast.mp3', 103 * rel: 'enclosure', 104 * type: 'audio/mpeg', 105 * length: 12345 106 * } 107 * ], 108 * title: { 109 * text: 'Juneau ATOM specification snapshot' 110 * }, 111 * updated: '2016-01-02T03:04:05Z', 112 * content: { 113 * base: 'http://www.apache.org/', 114 * lang: 'en', 115 * type: 'xhtml', 116 * text: '<div xmlns="http://www.w3.org/1999/xhtml"><p><i>[Update: Juneau supports ATOM.]</i></p></div>' 117 * }, 118 * published: '2016-01-02T03:04:05Z' 119 * } 120 * ] 121 * } 122 */ 123 String atomJson = s.serialize(feed); 124 } 125}