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.json; 014 015/** 016 * Parses any valid JSON text into a POJO model. 017 * 018 * <h5 class='topic'>Media types</h5> 019 * 020 * Handles <c>Content-Type</c> types: <bc>application/json5, text/json5</bc> 021 * 022 * <h5 class='topic'>Description</h5> 023 * 024 * Identical to {@link JsonParser} but with the media type <bc>application/json5</bc>. 025 * 026 * <h5 class='section'>Notes:</h5><ul> 027 * <li class='note'>This class is thread safe and reusable. 028 * </ul> 029 * 030 * <h5 class='section'>See Also:</h5><ul> 031 * <li class='link'><a class="doclink" href="../../../../index.html#jm.JsonDetails">JSON Details</a> 032 * </ul> 033 */ 034public class Json5Parser extends JsonParser { 035 036 //------------------------------------------------------------------------------------------------------------------- 037 // Static 038 //------------------------------------------------------------------------------------------------------------------- 039 040 /** Default parser, Accept=application/json5. */ 041 public static final Json5Parser DEFAULT = new Json5Parser(create()); 042 043 /** 044 * Creates a new builder for this object. 045 * 046 * @return A new builder. 047 */ 048 public static JsonParser.Builder create() { 049 return JsonParser.create().consumes("application/json5,text/json5,application/json,text/json"); 050 } 051 052 //------------------------------------------------------------------------------------------------------------------- 053 // Instance 054 //------------------------------------------------------------------------------------------------------------------- 055 056 /** 057 * Constructor. 058 * 059 * @param builder The builder for this object. 060 */ 061 public Json5Parser(JsonParser.Builder builder) { 062 super(builder); 063 } 064 065 @Override /* Context */ 066 public JsonParser.Builder copy() { 067 return new JsonParser.Builder(this); 068 } 069}