Preamble

The examples below are currently generated by the JON default writer. However, whitespace in the JON output has been added to aid readability.

Examples

Hello World

A flattened java.lang.Object instance

&0 = (&1 = java.lang.Object)
  {
  }

A single property POJO

The sample class IntegerObject defined below

public class IntegerObject{
        private int i;
}

Could serialize to something like

&0 = (&1 = sample.IntegerObject)
  {
  i: 15
  }

A POJO with more interesting members

public class SimpleObject{
        private String s;
        private IntegerObject io;
}
&0 = (&1 = sample.SimpleObject)
  {
  s: "howdy",
  io: &2 = 
    {
    i: 17
    }
  }

A self-referencing object

public class SelfReferencingObject{
        private SelfReferencingObject self;
}
&0 = (&1 = sample.SelfReferencingObject)
  {
  self: &0
  }

An int

3456

Null

null

A sub class

public class SimpleChild extends SimpleObject{
        private double s;
}
&0 = (&1 = sample.SimpleChild)
  {
  s: 12.234
  |
  s: "curious",
  io: &2 = 
    {
    i: 181
    }
  }

A sub class with no fields

public class SimpleGrandChild extends SimpleChild{
}
&0 = (&1 = sample.SimpleGrandChild)
  {
  s: 82.24
  |
  s: "bland",
  io: &2 = 
    {
    i: 134
    }
  }

A sub class with an array

public class SimpleGreatGrandChild extends SimpleGrandChild{
        private String[] s;
}
&0 = (&1 = sample.SimpleGreatGrandChild)
  {
  s: &2 = 
    [
    "crazy",
    "train"
    ]
  |
  s: -82.24
  |
  s: "nested goodness",
  io: &3 = 
    {
    i: 1624
    }
  }

A more complex example

public class ComplexChild extends SimpleChild{
}

public class IntegerChild extends IntegerObject{
        private List<String> list;
}
&0 = (&1 = sample.ComplexChild)
  {
  s: "wow",
  io: &2 = (&3 = sample.IntegerChild)
    {
    list: &4 = (&5 = java.util.ArrayList)
      [
      "bob",
      "was",
      "here"
      ]
    |
    i: 19
    }
  }

An enum example

public class EnumBox{
        public enum SampleEnum{
                ValueA
        }
        private SampleEnum e;
}
&0 = (&1 = sample.EnumBox)
  {
  e: ValueA
  }

A non-static inner child. Note: this will likely change when the reader is implemented.

public class InnerChild{
        public class Child{
                private int i;
        }
        private Child inner;
}
&0 = (&1 = sample.InnerChild)
  {
  inner: &2 = 
    {
    i: 1
    }
  }

A serialized java.util.HashMap

&0 = (&1 = java.util.HashMap)
  {
  "jon": "supercalifragilisticexpialidocious",
  "json": "great",
  "xml": "good"
  }