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   /** Default parser, Accept=application/json5. */
040   public static final Json5Parser DEFAULT = new Json5Parser(create());
041
042   /**
043    * Creates a new builder for this object.
044    *
045    * @return A new builder.
046    */
047   public static JsonParser.Builder create() {
048      return JsonParser.create().consumes("application/json5,text/json5,application/json,text/json");
049   }
050
051   /**
052    * Constructor.
053    *
054    * @param builder The builder for this object.
055    */
056   public Json5Parser(JsonParser.Builder builder) {
057      super(builder);
058   }
059
060   @Override /* Overridden from Context */
061   public JsonParser.Builder copy() {
062      return new JsonParser.Builder(this);
063   }
064}