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 015import org.apache.juneau.*; 016import org.apache.juneau.collections.*; 017 018/** 019 * Parses any valid JSON text into a POJO model. 020 * 021 * <h5 class='topic'>Media types</h5> 022 * 023 * Handles <c>Content-Type</c> types: <bc>application/json+simple, text/json+simple</bc> 024 * 025 * <h5 class='topic'>Description</h5> 026 * 027 * Identical to {@link JsonParser} but with the media type <bc>application/json+simple</bc>. 028 */ 029public class SimpleJsonParser extends JsonParser { 030 031 //------------------------------------------------------------------------------------------------------------------- 032 // Predefined instances 033 //------------------------------------------------------------------------------------------------------------------- 034 035 /** Default parser, Accept=application/json+simple. */ 036 public static final SimpleJsonParser DEFAULT = new SimpleJsonParser(PropertyStore.DEFAULT); 037 038 /** 039 * Constructor. 040 * 041 * @param ps The property store containing all the settings for this object. 042 */ 043 public SimpleJsonParser(PropertyStore ps) { 044 super(ps, "application/json+simple", "text/json+simple", "application/json", "text/json"); 045 } 046 047 @Override /* Context */ 048 public SimpleJsonParserBuilder builder() { 049 return new SimpleJsonParserBuilder(getPropertyStore()); 050 } 051 052 /** 053 * Instantiates a new clean-slate {@link SimpleJsonParserBuilder} object. 054 * 055 * <p> 056 * This is equivalent to simply calling <code><jk>new</jk> SimpleJsonParserBuilder()</code>. 057 * 058 * <p> 059 * Note that this method creates a builder initialized to all default settings, whereas {@link #builder()} copies 060 * the settings of the object called on. 061 * 062 * @return A new {@link SimpleJsonParserBuilder} object. 063 */ 064 public static SimpleJsonParserBuilder create() { 065 return new SimpleJsonParserBuilder(); 066 } 067 068 //----------------------------------------------------------------------------------------------------------------- 069 // Other methods 070 //----------------------------------------------------------------------------------------------------------------- 071 072 @Override /* Context */ 073 public OMap toMap() { 074 return super.toMap() 075 .a("SimpleJsonSerializer", new DefaultFilteringOMap() 076 ); 077 } 078}