001/*
002 * #%L
003 * HAPI FHIR - Core Library
004 * %%
005 * Copyright (C) 2014 - 2024 Smile CDR, Inc.
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 *
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package ca.uhn.fhir.parser.json;
021
022import ca.uhn.fhir.parser.DataFormatException;
023
024import java.io.IOException;
025import java.io.Reader;
026import java.io.Writer;
027
028/**
029 * This interface is the generic representation of any sort of data
030 * structure that looks and smells like JSON. These data structures
031 * can be abstractly viewed as a <code.Map</code> or <code>List</code>
032 * whose members are other Maps, Lists, or scalars (Strings, Numbers, Boolean)
033 *
034 * @author Bill.Denton
035 */
036public interface JsonLikeStructure {
037        JsonLikeStructure getInstance();
038
039        /**
040         * Parse the JSON document into the Json-like structure
041         * so that it can be navigated.
042         *
043         * @param theReader a <code>Reader</code> that will
044         *                  process the JSON input stream
045         * @throws DataFormatException when invalid JSON is received
046         */
047        void load(Reader theReader) throws DataFormatException;
048
049        void load(Reader theReader, boolean allowArray) throws DataFormatException;
050
051        BaseJsonLikeObject getRootObject() throws DataFormatException;
052
053        BaseJsonLikeWriter getJsonLikeWriter();
054
055        BaseJsonLikeWriter getJsonLikeWriter(Writer writer) throws IOException;
056}