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