001/*
002 * Copyright 2012-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.json;
018
019import java.util.List;
020import java.util.Map;
021
022/**
023 * Parser that can read JSON formatted strings into {@link Map}s or {@link List}s.
024 *
025 * @author Dave Syer
026 * @see JsonParserFactory
027 * @see BasicJsonParser
028 * @see JacksonJsonParser
029 * @see GsonJsonParser
030 * @see YamlJsonParser
031 */
032public interface JsonParser {
033
034        /**
035         * Parse the specified JSON string into a Map.
036         * @param json the JSON to parse
037         * @return the parsed JSON as a map
038         * @throws JsonParseException if the JSON cannot be parsed
039         */
040        Map<String, Object> parseMap(String json) throws JsonParseException;
041
042        /**
043         * Parse the specified JSON string into a List.
044         * @param json the JSON to parse
045         * @return the parsed JSON as a list
046         * @throws JsonParseException if the JSON cannot be parsed
047         */
048        List<Object> parseList(String json) throws JsonParseException;
049
050}