001/* Copyright 2016 Clifton Labs 002 * Licensed under the Apache License, Version 2.0 (the "License"); 003 * you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at 005 * http://www.apache.org/licenses/LICENSE-2.0 006 * Unless required by applicable law or agreed to in writing, software 007 * distributed under the License is distributed on an "AS IS" BASIS, 008 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 009 * See the License for the specific language governing permissions and 010 * limitations under the License. */ 011package org.json.simple; 012 013import java.io.IOException; 014import java.io.Writer; 015 016/** Jsonables can be serialized in java script object notation (JSON). Deserializing a String produced by a Jsonable 017 * should represent the Jsonable in JSON form. 018 * @since 2.0.0 */ 019public interface Jsonable{ 020 /** Serialize to a JSON formatted string. 021 * @return a string, formatted in JSON, that represents the Jsonable. */ 022 public String toJson(); 023 024 /** Serialize to a JSON formatted stream. 025 * @param writable where the resulting JSON text should be sent. 026 * @throws IOException when the writable encounters an I/O error. */ 027 public void toJson(Writer writable) throws IOException; 028}