@Test
public void testSerialize() throws JVoiceXMLEvent {

    final DataModel model = new EcmaScriptDataModel();
    model.createScope(Scope.SESSION);
    model.evaluateExpression("var A = new Object();", Object.class);
    model.evaluateExpression("A.B = 'test';", Object.class);
    model.evaluateExpression("A.C = new Object();", Object.class);
    model.evaluateExpression("A.C.D = 42.0;", Object.class);
    model.evaluateExpression("A.C.E = null;", Object.class);
    final DataModelObjectSerializer serializer = new JSONSerializer();
    final Object object = model.readVariable("A", Object.class);
    final Collection<KeyValuePair> pairs = serializer.serialize(model, "A",
            object);
    Assert.assertEquals(1, pairs.size());
    final Iterator<KeyValuePair> iterator = pairs.iterator();
    final KeyValuePair pair = iterator.next();
    Assert.assertEquals("A", pair.getKey());
    Assert.assertEquals("{\"B\":\"test\",\"C\":{\"D\":42,\"E\":null}}",
            pair.getValue());
}