<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_35) on Tue Oct 09 17:08:07 PDT 2012 --> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE> JsonSerializable (jackson-databind 2.1.0 API) </TITLE> <META NAME="date" CONTENT="2012-10-09"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="JsonSerializable (jackson-databind 2.1.0 API)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/JsonSerializable.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../com/fasterxml/jackson/databind/JsonNode.html" title="class in com.fasterxml.jackson.databind"><B>PREV CLASS</B></A> <A HREF="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="class in com.fasterxml.jackson.databind"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?com/fasterxml/jackson/databind/JsonSerializable.html" target="_top"><B>FRAMES</B></A> <A HREF="JsonSerializable.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <!-- ======== START OF CLASS DATA ======== --> <H2> <FONT SIZE="-1"> com.fasterxml.jackson.databind</FONT> <BR> Interface JsonSerializable</H2> <DL> <DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../../com/fasterxml/jackson/databind/node/ArrayNode.html" title="class in com.fasterxml.jackson.databind.node">ArrayNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/type/ArrayType.html" title="class in com.fasterxml.jackson.databind.type">ArrayType</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/BaseJsonNode.html" title="class in com.fasterxml.jackson.databind.node">BaseJsonNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/BigIntegerNode.html" title="class in com.fasterxml.jackson.databind.node">BigIntegerNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/BinaryNode.html" title="class in com.fasterxml.jackson.databind.node">BinaryNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/BooleanNode.html" title="class in com.fasterxml.jackson.databind.node">BooleanNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/type/CollectionLikeType.html" title="class in com.fasterxml.jackson.databind.type">CollectionLikeType</A>, <A HREF="../../../../com/fasterxml/jackson/databind/type/CollectionType.html" title="class in com.fasterxml.jackson.databind.type">CollectionType</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/ContainerNode.html" title="class in com.fasterxml.jackson.databind.node">ContainerNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/DecimalNode.html" title="class in com.fasterxml.jackson.databind.node">DecimalNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/DoubleNode.html" title="class in com.fasterxml.jackson.databind.node">DoubleNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/IntNode.html" title="class in com.fasterxml.jackson.databind.node">IntNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/util/JSONPObject.html" title="class in com.fasterxml.jackson.databind.util">JSONPObject</A>, <A HREF="../../../../com/fasterxml/jackson/databind/util/JSONWrappedObject.html" title="class in com.fasterxml.jackson.databind.util">JSONWrappedObject</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/LongNode.html" title="class in com.fasterxml.jackson.databind.node">LongNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/type/MapLikeType.html" title="class in com.fasterxml.jackson.databind.type">MapLikeType</A>, <A HREF="../../../../com/fasterxml/jackson/databind/type/MapType.html" title="class in com.fasterxml.jackson.databind.type">MapType</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/MissingNode.html" title="class in com.fasterxml.jackson.databind.node">MissingNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/NullNode.html" title="class in com.fasterxml.jackson.databind.node">NullNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/NumericNode.html" title="class in com.fasterxml.jackson.databind.node">NumericNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/ObjectNode.html" title="class in com.fasterxml.jackson.databind.node">ObjectNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/POJONode.html" title="class in com.fasterxml.jackson.databind.node">POJONode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/type/SimpleType.html" title="class in com.fasterxml.jackson.databind.type">SimpleType</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/TextNode.html" title="class in com.fasterxml.jackson.databind.node">TextNode</A>, <A HREF="../../../../com/fasterxml/jackson/databind/type/TypeBase.html" title="class in com.fasterxml.jackson.databind.type">TypeBase</A>, <A HREF="../../../../com/fasterxml/jackson/databind/node/ValueNode.html" title="class in com.fasterxml.jackson.databind.node">ValueNode</A></DD> </DL> <HR> <DL> <DT><PRE>public interface <B>JsonSerializable</B></DL> </PRE> <P> Interface that can be implemented by objects that know how to serialize themselves to JSON, using <A HREF="http://fasterxml.github.com/jackson-core/javadoc/2.1.0/com/fasterxml/jackson/core/JsonGenerator.html?is-external=true" title="class or interface in com.fasterxml.jackson.core"><CODE>JsonGenerator</CODE></A> (and <A HREF="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind"><CODE>SerializerProvider</CODE></A> if necessary). <p> Note that implementing this interface binds implementing object closely to Jackson API, and that it is often not necessary to do so -- if class is a bean, it can be serialized without implementing this interface. <p> NOTE: Jackson 2.0 added another method (from former "JsonSerializableWithType"), which is required for proper handling of case where additional type information is needed. <P> <P> <HR> <P> <!-- ========== METHOD SUMMARY =========== --> <A NAME="method_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Method Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/fasterxml/jackson/databind/JsonSerializable.html#serialize(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider)">serialize</A></B>(<A HREF="http://fasterxml.github.com/jackson-core/javadoc/2.1.0/com/fasterxml/jackson/core/JsonGenerator.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonGenerator</A> jgen, <A HREF="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind">SerializerProvider</A> provider)</CODE> <BR> Serialization method called when no additional type information is to be included in serialization.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/fasterxml/jackson/databind/JsonSerializable.html#serializeWithType(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.jsontype.TypeSerializer)">serializeWithType</A></B>(<A HREF="http://fasterxml.github.com/jackson-core/javadoc/2.1.0/com/fasterxml/jackson/core/JsonGenerator.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonGenerator</A> jgen, <A HREF="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind">SerializerProvider</A> provider, <A HREF="../../../../com/fasterxml/jackson/databind/jsontype/TypeSerializer.html" title="class in com.fasterxml.jackson.databind.jsontype">TypeSerializer</A> typeSer)</CODE> <BR> Serialization method called when additional type information is expected to be included in serialization, for deserialization to use.</TD> </TR> </TABLE> <P> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Method Detail</B></FONT></TH> </TR> </TABLE> <A NAME="serialize(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider)"><!-- --></A><H3> serialize</H3> <PRE> void <B>serialize</B>(<A HREF="http://fasterxml.github.com/jackson-core/javadoc/2.1.0/com/fasterxml/jackson/core/JsonGenerator.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonGenerator</A> jgen, <A HREF="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind">SerializerProvider</A> provider) throws <A HREF="http://docs.oracle.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A>, <A HREF="http://fasterxml.github.com/jackson-core/javadoc/2.1.0/com/fasterxml/jackson/core/JsonProcessingException.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonProcessingException</A></PRE> <DL> <DD>Serialization method called when no additional type information is to be included in serialization. <P> <DD><DL> <DT><B>Throws:</B> <DD><CODE><A HREF="http://docs.oracle.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE> <DD><CODE><A HREF="http://fasterxml.github.com/jackson-core/javadoc/2.1.0/com/fasterxml/jackson/core/JsonProcessingException.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonProcessingException</A></CODE></DL> </DD> </DL> <HR> <A NAME="serializeWithType(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.jsontype.TypeSerializer)"><!-- --></A><H3> serializeWithType</H3> <PRE> void <B>serializeWithType</B>(<A HREF="http://fasterxml.github.com/jackson-core/javadoc/2.1.0/com/fasterxml/jackson/core/JsonGenerator.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonGenerator</A> jgen, <A HREF="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind">SerializerProvider</A> provider, <A HREF="../../../../com/fasterxml/jackson/databind/jsontype/TypeSerializer.html" title="class in com.fasterxml.jackson.databind.jsontype">TypeSerializer</A> typeSer) throws <A HREF="http://docs.oracle.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A>, <A HREF="http://fasterxml.github.com/jackson-core/javadoc/2.1.0/com/fasterxml/jackson/core/JsonProcessingException.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonProcessingException</A></PRE> <DL> <DD>Serialization method called when additional type information is expected to be included in serialization, for deserialization to use. <p> Usually implementation consists of a call to one of methods in <A HREF="../../../../com/fasterxml/jackson/databind/jsontype/TypeSerializer.html" title="class in com.fasterxml.jackson.databind.jsontype"><CODE>TypeSerializer</CODE></A> (such as <A HREF="../../../../com/fasterxml/jackson/databind/jsontype/TypeSerializer.html#writeTypePrefixForObject(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator)"><CODE>TypeSerializer.writeTypePrefixForObject(Object, JsonGenerator)</CODE></A>) followed by serialization of contents, followed by another call to <A HREF="../../../../com/fasterxml/jackson/databind/jsontype/TypeSerializer.html" title="class in com.fasterxml.jackson.databind.jsontype"><CODE>TypeSerializer</CODE></A> (such as <A HREF="../../../../com/fasterxml/jackson/databind/jsontype/TypeSerializer.html#writeTypeSuffixForObject(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator)"><CODE>TypeSerializer.writeTypeSuffixForObject(Object, JsonGenerator)</CODE></A>). Exact methods to call in <A HREF="../../../../com/fasterxml/jackson/databind/jsontype/TypeSerializer.html" title="class in com.fasterxml.jackson.databind.jsontype"><CODE>TypeSerializer</CODE></A> depend on shape of JSON Object used (Array, Object or scalar like String/Number/Boolean). <p> Note that some types (most notably, "natural" types: String, Integer, Double and Boolean) never include type information. <P> <DD><DL> <DT><B>Throws:</B> <DD><CODE><A HREF="http://docs.oracle.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE> <DD><CODE><A HREF="http://fasterxml.github.com/jackson-core/javadoc/2.1.0/com/fasterxml/jackson/core/JsonProcessingException.html?is-external=true" title="class or interface in com.fasterxml.jackson.core">JsonProcessingException</A></CODE></DL> </DD> </DL> <!-- ========= END OF CLASS DATA ========= --> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/JsonSerializable.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../com/fasterxml/jackson/databind/JsonNode.html" title="class in com.fasterxml.jackson.databind"><B>PREV CLASS</B></A> <A HREF="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="class in com.fasterxml.jackson.databind"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?com/fasterxml/jackson/databind/JsonSerializable.html" target="_top"><B>FRAMES</B></A> <A HREF="JsonSerializable.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> Copyright © 2012 <a href="http://fasterxml.com/">FasterXML</a>. All Rights Reserved. </BODY> </HTML>