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