Skip to main content

HTML Methodology

The following examples show how different data types are represented in HTML. They mirror how the data structures are represented in JSON.

Simple types

The representation for simple types mirror 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>
Maps

Maps and beans are represented as tables. The _type attribute is added to differentiate between objects (Maps/beans) and arrays (arrays/Collections).

Data typeJSON exampleHTML
Map
{
k1: 'v1',
k2: null
}
<table _type='object'>
<tr>
<td>k1</td>
<td>v1</td>
</tr>
<tr>
<td>k2</td>
<td><null></null></td>
</tr>
</table>
Map
{
k1: 123,
k2: 1.23,
k3: null
}
<table _type='object'>
<tr>
<td>k1</td>
<td><number>123</number></td>
</tr>
<tr>
<td>k2</td>
<td><number>1.23</number></td>
</tr>
<tr>
<td>k3</td>
<td><null></null></td>
</tr>
</table>
Map
{
k1: 'v1',
k2: 123,
k3: 1.23,
k4: true,
k5: null
}
<table _type='object'>
<tr>
<td>k1</td>
<td>v1</td>
</tr>
<tr>
<td>k2</td>
<td><number>123</number></td>
</tr>
<tr>
<td>k3</td>
<td><number>1.23</number></td>
</tr>
<tr>
<td>k4</td>
<td><boolean>true</boolean></td>
</tr>
<tr>
<td>k5</td>
<td><null></null></td>
</tr>
</table>
Arrays

Collections and arrays are represented as ordered lists.

Data typeJSON exampleHTML
String[]
['foo', null]
<ul>
<li>foo</li>
<li><null></null></li>
</ul>
Number[]
[123, 1.23, null]
<ul>
<li><number>123</number></li>
<li><number>1.23</number></li>
<li><null></null></li>
</ul>
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>
String[][]
[['foo', null], null]
<ul>
<li>
<ul>
<li>foo</li>
<li><null></null></li>
</ul>
</li>
<li><null></null></li>
</ul>
int[]
[123]
<ul>
<li><number>123</number></li>
</ul>
boolean[]
[true]
<ul>
<li><boolean>true</boolean></li>
</ul>
Collections
Data typeJSON exampleHTML
List<String>
['foo', null]
<ul>
<li>foo</li>
<li><null></null></li>
</ul>
List<Number>
[123, 1.23, null]
<ul>
<li><number>123</number></li>
<li><number>1.23</number></li>
<li><null></null></li>
</ul>
List<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>
Beans
Data typeJSON exampleHTML
class MyBean {
public String a;
public int b;
public Object c; // String value
public Object d; // Integer value
public MyBean2 e;
public String[] f;
public int[] g;
}

class MyBean2 {
String h;
}
{
a: 'foo',
b: 123,
c: 'bar',
d: 456,
e: {
h: 'baz'
},
f: ['qux'],
g: [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>bar</td>
</tr>
<tr>
<td>d</td>
<td><number>456</number></td>
</tr>
<tr>
<td>e</td>
<td>
<table _type='object'>
<tr>
<td>h</td>
<td>baz</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>f</td>
<td>
<ul>
<li>qux</li>
</ul>
</td>
</tr>
<tr>
<td>g</td>
<td>
<ul>
<li><number>789</number></li>
</ul>
</td>
</tr>
</table>
Beans with Map properties
Data typeJSON exampleHTML
class MyBean {
public Map a;
public Map b;
public Map c;
}
{
a: { k1: 'foo' },
b: { k2: 123 },
c: {
k3: 'bar',
k4: 456,
k5: true,
k6: null
}
}
<table _type='object'>
<tr>
<td>a</td>
<td>
<table _type='object'>
<tr>
<td>k1</td>
<td>foo</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>b</td>
<td>
<table _type='object'>
<tr>
<td>k2</td>
<td><number>123</number></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>c</td>
<td>
<table _type='object'>
<tr>
<td>k3</td>
<td>bar</td>
</tr>
<tr>
<td>k4</td>
<td><number>456</number></td>
</tr>
<tr>
<td>k5</td>
<td><boolean>true</boolean></td>
</tr>
<tr>
<td>k6</td>
<td><null></null></td>
</tr>
</table>
</td>
</tr>
</table>