• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<!--NewPage-->
3<HTML>
4<HEAD>
5<!-- Generated by javadoc (build 1.6.0_29) on Mon Mar 26 19:07:10 PDT 2012 -->
6<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
7<TITLE>
8JsonSerializable (jackson-databind 2.0.0 API)
9</TITLE>
10
11<META NAME="date" CONTENT="2012-03-26">
12
13<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
14
15<SCRIPT type="text/javascript">
16function windowTitle()
17{
18    if (location.href.indexOf('is-external=true') == -1) {
19        parent.document.title="JsonSerializable (jackson-databind 2.0.0 API)";
20    }
21}
22</SCRIPT>
23<NOSCRIPT>
24</NOSCRIPT>
25
26</HEAD>
27
28<BODY BGCOLOR="white" onload="windowTitle();">
29<HR>
30
31
32<!-- ========= START OF TOP NAVBAR ======= -->
33<A NAME="navbar_top"><!-- --></A>
34<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
35<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
36<TR>
37<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
38<A NAME="navbar_top_firstrow"><!-- --></A>
39<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
40  <TR ALIGN="center" VALIGN="top">
41  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
42  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
43  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
44  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/JsonSerializable.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
45  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
46  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
47  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
48  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
49  </TR>
50</TABLE>
51</TD>
52<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
53</EM>
54</TD>
55</TR>
56
57<TR>
58<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
59&nbsp;<A HREF="../../../../com/fasterxml/jackson/databind/JsonNode.html" title="class in com.fasterxml.jackson.databind"><B>PREV CLASS</B></A>&nbsp;
60&nbsp;<A HREF="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="class in com.fasterxml.jackson.databind"><B>NEXT CLASS</B></A></FONT></TD>
61<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
62  <A HREF="../../../../index.html?com/fasterxml/jackson/databind/JsonSerializable.html" target="_top"><B>FRAMES</B></A>  &nbsp;
63&nbsp;<A HREF="JsonSerializable.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
64&nbsp;<SCRIPT type="text/javascript">
65  <!--
66  if(window==top) {
67    document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
68  }
69  //-->
70</SCRIPT>
71<NOSCRIPT>
72  <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
73</NOSCRIPT>
74
75
76</FONT></TD>
77</TR>
78<TR>
79<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
80  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
81<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
82DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
83</TR>
84</TABLE>
85<A NAME="skip-navbar_top"></A>
86<!-- ========= END OF TOP NAVBAR ========= -->
87
88<HR>
89<!-- ======== START OF CLASS DATA ======== -->
90<H2>
91<FONT SIZE="-1">
92com.fasterxml.jackson.databind</FONT>
93<BR>
94Interface JsonSerializable</H2>
95<DL>
96<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>
97</DL>
98<HR>
99<DL>
100<DT><PRE>public interface <B>JsonSerializable</B></DL>
101</PRE>
102
103<P>
104Interface that can be implemented by objects that know how to
105 serialize themselves to JSON, using <CODE>JsonGenerator</CODE>
106 (and <A HREF="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind"><CODE>SerializerProvider</CODE></A> if necessary).
107<p>
108 Note that implementing this interface binds implementing object
109 closely to Jackson API, and that it is often not necessary to do
110 so -- if class is a bean, it can be serialized without
111 implementing this interface.
112<p>
113 NOTE: Jackson 2.0 added another method (from former "JsonSerializableWithType"),
114 which is required for proper handling of case where additional type information
115 is needed.
116<P>
117
118<P>
119<HR>
120
121<P>
122
123<!-- ========== METHOD SUMMARY =========== -->
124
125<A NAME="method_summary"><!-- --></A>
126<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
127<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
128<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
129<B>Method Summary</B></FONT></TH>
130</TR>
131<TR BGCOLOR="white" CLASS="TableRowColor">
132<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
133<CODE>&nbsp;void</CODE></FONT></TD>
134<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>(com.fasterxml.jackson.core.JsonGenerator&nbsp;jgen,
135          <A HREF="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind">SerializerProvider</A>&nbsp;provider)</CODE>
136
137<BR>
138&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Serialization method called when no additional type information is
139 to be included in serialization.</TD>
140</TR>
141<TR BGCOLOR="white" CLASS="TableRowColor">
142<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
143<CODE>&nbsp;void</CODE></FONT></TD>
144<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>(com.fasterxml.jackson.core.JsonGenerator&nbsp;jgen,
145                  <A HREF="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind">SerializerProvider</A>&nbsp;provider,
146                  <A HREF="../../../../com/fasterxml/jackson/databind/jsontype/TypeSerializer.html" title="class in com.fasterxml.jackson.databind.jsontype">TypeSerializer</A>&nbsp;typeSer)</CODE>
147
148<BR>
149&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Serialization method called when additional type information is
150 expected to be included in serialization, for deserialization to use.</TD>
151</TR>
152</TABLE>
153&nbsp;
154<P>
155
156<!-- ============ METHOD DETAIL ========== -->
157
158<A NAME="method_detail"><!-- --></A>
159<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
160<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
161<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
162<B>Method Detail</B></FONT></TH>
163</TR>
164</TABLE>
165
166<A NAME="serialize(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider)"><!-- --></A><H3>
167serialize</H3>
168<PRE>
169void <B>serialize</B>(com.fasterxml.jackson.core.JsonGenerator&nbsp;jgen,
170               <A HREF="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind">SerializerProvider</A>&nbsp;provider)
171               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>,
172                      com.fasterxml.jackson.core.JsonProcessingException</PRE>
173<DL>
174<DD>Serialization method called when no additional type information is
175 to be included in serialization.
176<P>
177<DD><DL>
178
179<DT><B>Throws:</B>
180<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>
181<DD><CODE>com.fasterxml.jackson.core.JsonProcessingException</CODE></DL>
182</DD>
183</DL>
184<HR>
185
186<A NAME="serializeWithType(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.jsontype.TypeSerializer)"><!-- --></A><H3>
187serializeWithType</H3>
188<PRE>
189void <B>serializeWithType</B>(com.fasterxml.jackson.core.JsonGenerator&nbsp;jgen,
190                       <A HREF="../../../../com/fasterxml/jackson/databind/SerializerProvider.html" title="class in com.fasterxml.jackson.databind">SerializerProvider</A>&nbsp;provider,
191                       <A HREF="../../../../com/fasterxml/jackson/databind/jsontype/TypeSerializer.html" title="class in com.fasterxml.jackson.databind.jsontype">TypeSerializer</A>&nbsp;typeSer)
192                       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>,
193                              com.fasterxml.jackson.core.JsonProcessingException</PRE>
194<DL>
195<DD>Serialization method called when additional type information is
196 expected to be included in serialization, for deserialization to use.
197<p>
198 Usually implementation consists of a call to one of methods
199 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>)
200 followed by serialization of contents,
201 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>
202 (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>).
203 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
204 (Array, Object or scalar like String/Number/Boolean).
205<p>
206 Note that some types (most notably, "natural" types: String, Integer,
207 Double and Boolean) never include type information.
208<P>
209<DD><DL>
210
211<DT><B>Throws:</B>
212<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>
213<DD><CODE>com.fasterxml.jackson.core.JsonProcessingException</CODE></DL>
214</DD>
215</DL>
216<!-- ========= END OF CLASS DATA ========= -->
217<HR>
218
219
220<!-- ======= START OF BOTTOM NAVBAR ====== -->
221<A NAME="navbar_bottom"><!-- --></A>
222<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
223<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
224<TR>
225<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
226<A NAME="navbar_bottom_firstrow"><!-- --></A>
227<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
228  <TR ALIGN="center" VALIGN="top">
229  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
230  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
231  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
232  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/JsonSerializable.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
233  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
234  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
235  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
236  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
237  </TR>
238</TABLE>
239</TD>
240<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
241</EM>
242</TD>
243</TR>
244
245<TR>
246<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
247&nbsp;<A HREF="../../../../com/fasterxml/jackson/databind/JsonNode.html" title="class in com.fasterxml.jackson.databind"><B>PREV CLASS</B></A>&nbsp;
248&nbsp;<A HREF="../../../../com/fasterxml/jackson/databind/JsonSerializer.html" title="class in com.fasterxml.jackson.databind"><B>NEXT CLASS</B></A></FONT></TD>
249<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
250  <A HREF="../../../../index.html?com/fasterxml/jackson/databind/JsonSerializable.html" target="_top"><B>FRAMES</B></A>  &nbsp;
251&nbsp;<A HREF="JsonSerializable.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
252&nbsp;<SCRIPT type="text/javascript">
253  <!--
254  if(window==top) {
255    document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
256  }
257  //-->
258</SCRIPT>
259<NOSCRIPT>
260  <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
261</NOSCRIPT>
262
263
264</FONT></TD>
265</TR>
266<TR>
267<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
268  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
269<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
270DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
271</TR>
272</TABLE>
273<A NAME="skip-navbar_bottom"></A>
274<!-- ======== END OF BOTTOM NAVBAR ======= -->
275
276<HR>
277Copyright &#169; 2012 <a href="http://fasterxml.com">fasterxml.com</a>. All Rights Reserved.
278</BODY>
279</HTML>
280