001/* 002 * (C) Copyright 2006-2010 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * bstefanescu 016 */ 017package org.nuxeo.ecm.automation.jaxrs; 018 019import java.io.IOException; 020import java.io.OutputStream; 021 022/** 023 * Should be implemented by objects that needs to be returned in response to clients as JSOn objects 024 * <p> 025 * Implementors are encouraged to use jackson JSON library since it is the one used by automation. 026 * <p> 027 * Also <b>note</b> that the JSON format for an object must follow the following schema: 028 * 029 * <pre> 030 * { 031 * "entity-type": "typeName" 032 * "value": { the marshalled object } 033 * } 034 * </pre> 035 * 036 * The value is either a scalar value (from primitive types) either a JSON object <code>{ ... }</code> The type name is 037 * the full class name of the serialized object. The primitive types are mapped to a short name as following: 038 * <ul> 039 * <li>string 040 * <li>date 041 * <li>boolean 042 * <li>long 043 * <li>double 044 * <li>null - this is a special type in case the objec is null - but this may never happens (since null objects are 045 * returning an empty content) 046 * </ul> 047 * 048 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 049 */ 050public interface JsonAdapter { 051 052 void toJSON(OutputStream out) throws IOException; 053 054}