Skip to main content

HTML Methodology

This page describes how the different POJO datatypes are represented in HTML. The representations mirror how the same data structures are represented in JSON, and build directly on the XML Methodology:

  • Simple values (strings, numbers, booleans, nulls) render as text, with lightweight type tags added only where the datatype cannot be inferred through reflection.
  • Maps and beans render as <table> elements.
  • Collections and arrays render as <ul> bulleted lists.

The examples below show one representative case per category. For the complete set of data-type representations (all Map, array, Collection, and bean shapes), see the reference tables on the HTML Serializers page.

Simple types​

The representation for simple types mirrors those produced by the XML serializer. Tags are added to help differentiate data types when they cannot be inferred through reflection. These tags are ignored by browsers and treated as plain text.

Data typeJSON exampleHTML
string
'foo'
foo
boolean
true
<boolean>true</boolean>
integer
123
<number>123</number>
float
1.23
<number>1.23</number>
null
null
<null></null>

Objects​

Maps and beans are represented as tables. The _type='object' attribute distinguishes objects (Maps/beans) from arrays (arrays/Collections), and per-cell type tags are added only where the value type cannot be inferred through reflection.

The following representative example shows a bean containing simple values, a nested bean, and array properties:

Data typeJSON exampleHTML
class MyBean {
public String a;
public int b;
public MyBean2 c;
public int[] d;
}

class MyBean2 {
String h;
}
{
a: 'foo',
b: 123,
c: {
h: 'baz'
},
d: [789]
}
<table _type='object'>
<tr>
<td>a</td>
<td>foo</td>
</tr>
<tr>
<td>b</td>
<td><number>123</number></td>
</tr>
<tr>
<td>c</td>
<td>
<table _type='object'>
<tr>
<td>h</td>
<td>baz</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>d</td>
<td>
<ul>
<li><number>789</number></li>
</ul>
</td>
</tr>
</table>

Arrays and collections​

Collections and arrays are represented as <ul> ordered lists, with type tags added to individual <li> elements as needed. Collections (e.g. List, Set) serialize identically to their array equivalents.

The following representative example shows a mixed-type Object[]:

Data typeJSON exampleHTML
Object[]
['foo', 123, 1.23, true, null]
<ul>
<li>foo</li>
<li><number>123</number></li>
<li><number>1.23</number></li>
<li><boolean>true</boolean></li>
<li><null></null></li>
</ul>