Commits

John Marsden committed 492ee89

Update before monster merge

  • Participants
  • Parent commits 6122b18

Comments (0)

Files changed (24)

File src/main/java/cc/plural/jsonij/FastJSONParser.java

  */
 package cc.plural.jsonij;
 
-import static cc.plural.jsonij.Constants.BACKSPACE;
-import static cc.plural.jsonij.Constants.BACKSPACE_CHAR;
-import static cc.plural.jsonij.Constants.CARRIAGE_RETURN;
-import static cc.plural.jsonij.Constants.CARRIAGE_RETURN_CHAR;
-import static cc.plural.jsonij.Constants.CLOSE_ARRAY;
-import static cc.plural.jsonij.Constants.CLOSE_OBJECT;
-import static cc.plural.jsonij.Constants.DECIMAL_POINT;
-import static cc.plural.jsonij.Constants.DIGITS;
-import static cc.plural.jsonij.Constants.ESCAPE;
-import static cc.plural.jsonij.Constants.EXPS;
-import static cc.plural.jsonij.Constants.FALSE_STR;
-import static cc.plural.jsonij.Constants.FORM_FEED;
-import static cc.plural.jsonij.Constants.FORM_FEED_CHAR;
-import static cc.plural.jsonij.Constants.HEX_CHAR;
-import static cc.plural.jsonij.Constants.MINUS;
-import static cc.plural.jsonij.Constants.NAME_SEPARATOR;
-import static cc.plural.jsonij.Constants.NEW_LINE;
-import static cc.plural.jsonij.Constants.NEW_LINE_CHAR;
-import static cc.plural.jsonij.Constants.NULL_STR;
-import static cc.plural.jsonij.Constants.OPEN_ARRAY;
-import static cc.plural.jsonij.Constants.OPEN_OBJECT;
-import static cc.plural.jsonij.Constants.PLUS;
-import static cc.plural.jsonij.Constants.DOUBLE_QUOTE;
-import static cc.plural.jsonij.Constants.QUOTATION_MARK;
-import static cc.plural.jsonij.Constants.REVERSE_SOLIDUS;
-import static cc.plural.jsonij.Constants.SOLIDUS_CHAR;
-import static cc.plural.jsonij.Constants.TAB;
-import static cc.plural.jsonij.Constants.TAB_CHAR;
-import static cc.plural.jsonij.Constants.TRUE_STR;
-import static cc.plural.jsonij.Constants.VALUE_SEPARATOR;
-
-import cc.plural.jsonij.parser.ParserException;
-import cc.plural.jsonij.parser.ReaderParser;
 import java.io.IOException;
 import java.io.Reader;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 
+import cc.plural.jsonij.parser.ParserException;
+import cc.plural.jsonij.parser.ReaderParser;
 
+import static cc.plural.jsonij.Constants.*;
 
 /**
  *
- * @author jmarsden
+ * @author jmarsden@plural.cc
  */
 public class FastJSONParser extends JSONParser {
     

File src/main/java/cc/plural/jsonij/JSON.java

 
     @Override
     public java.lang.String toString() {
-        return java.lang.String.format("JSON@%s:%s", hashCode(), getRoot().toString());
+        return java.lang.String.format("JSON@%s:%s", Integer.toHexString(hashCode()), getRoot().toString());
     }
 
     @Override

File src/main/java/cc/plural/jsonij/JSONMarshaler.java

-/**
- * Copyright (C) 2010-2011 J.W.Marsden
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- **/
-package cc.plural.jsonij;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import cc.plural.jsonij.marshal.JSONDocumentMarshaler;
-import cc.plural.jsonij.marshal.JSONMarshalerException;
-import cc.plural.jsonij.marshal.JavaMarshaler;
-import cc.plural.jsonij.parser.ParserException;
-
-/**
- *
- * @author openecho
- */
-public class JSONMarshaler {
-
-    protected static final JavaMarshaler javaMarshaler;
-    protected static final JSONDocumentMarshaler jsonMarshaler;
-
-    static {
-        javaMarshaler = new JavaMarshaler();
-        jsonMarshaler = new JSONDocumentMarshaler();
-    }
-
-    public static JSON marshalObject(Object o) {
-        Value mashaledObject = javaMarshaler.marshalObject(o);
-        return new JSON(mashaledObject);
-    }
-
-    public static JSON marshalObject(boolean[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(Boolean[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(int[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(Integer[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(char[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(Character[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(double[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(Double[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(float[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(Float[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(short[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(Short[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(long[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(Long[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(String[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-
-    public static JSON marshalObject(Object[] a) {
-        Value marshaledArray = javaMarshaler.marshalObject(a);
-        return new JSON(marshaledArray);
-    }
-    
-    public static Object marshalJSON(String json, Class<?> c) throws JSONMarshalerException, IOException, ParserException {
-        Object marshaledObject = jsonMarshaler.marshalJSONDocument(JSON.parse(json), c);
-        return marshaledObject;
-    }
-    
-    public static Object marshalJSON(JSON json, Class<?> c) throws JSONMarshalerException {
-        Object marshaledObject = jsonMarshaler.marshalJSONDocument(json, c);
-        return marshaledObject;
-    }
-    
-    public static Object marshalJSON(Value value, Class<?> c) throws JSONMarshalerException {
-        Object marshaledObject = jsonMarshaler.marshalJSONDocument(value, c);
-        return marshaledObject;
-    }
-    
-    public static Object marshalJSON(InputStream stream, Class<?> c) throws JSONMarshalerException {
-        Object marshaledObject = jsonMarshaler.marshalJSONDocument(stream, c);
-        return marshaledObject;
-    }
-}

File src/main/java/cc/plural/jsonij/marshal/JSONDocumentMarshaler.java

 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
  */
 public class JSONDocumentMarshaler {
 
-    public static String innerArrayAttribute;
-
-    public static String innerObjectAttribute;
-
-    static {
-        innerArrayAttribute = "_innerArray";
-        innerObjectAttribute = "_innerObject";
-    }
-
     public Object marshalJSONDocument(JSON json, Class<?> objectClass) throws JSONMarshalerException {
         Object resultObject = null;
         Value jsonRoot = json.getRoot();
     }
 
     public Object marshalJSONDocumentObject(JSON.Object<CharSequence, Value> jsonObject, Class<?> objectClass) throws JSONMarshalerException {
-        Object resultObject = null;
+        Object object = null;
 
-        Set<Entry<CharSequence, Value>> entrySet = jsonObject.entrySet();
-        Iterator<Entry<CharSequence, Value>> entrySetIterator = entrySet.iterator();
-        Entry<CharSequence, Value> entry = null;
         Inspector inspector = new Inspector(objectClass);
         inspector.inspect();
 
         boolean hasCollector = inspector.hasCollector();
-        Map<CharSequence, Value> collectorReference = null;
-
-        List<MarshalerPropertyValue> objectPropertyValues = new ArrayList<MarshalerPropertyValue>();
-        List<MarshalerPropertyValue> collectorPropertyValues = null;
+        try {
+            object = objectClass.newInstance();
+        } catch(InstantiationException ex) {
+            Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+            throw new JSONMarshalerException("newInstance");
+        } catch(IllegalAccessException ex) {
+            Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+            throw new JSONMarshalerException("illegalAccess");
+        }
 
+        Map<CharSequence, Value> collector = null;
+        Map<CharSequence, Value> innerObjectCollector = null;
         if(hasCollector) {
-            collectorPropertyValues = new ArrayList<MarshalerPropertyValue>();
+            collector = new HashMap<CharSequence, Value>();
         }
-
-        while(entrySetIterator.hasNext()) {
-            entry = entrySetIterator.next();
-            if(entry.getKey().toString().equals(innerObjectAttribute) && inspector.hasInnerObject()) {
-                /**
-                 * todo: handle the inner object
-                 */
-            }
-            String propertyName = entry.getKey().toString();
-            if(inspector.hasProperty(propertyName)) {
-                MarshalerPropertyValue propertyValue = new MarshalerPropertyValue(propertyName, inspector.getProperty(propertyName), entry.getValue());
-                objectPropertyValues.add(propertyValue);
-            } else if(hasCollector) {
-                MarshalerPropertyValue propertyValue = new MarshalerPropertyValue(propertyName, inspector.getProperty(propertyName), entry.getValue());
-                collectorPropertyValues.add(propertyValue);
-            }
+        if(inspector.hasInnerObject()) {
+            innerObjectCollector = new HashMap<CharSequence, Value>();
         }
-
-        try {
-            resultObject = objectClass.newInstance();
-            if(hasCollector) {
-                InspectorProperty prop = inspector.getCollector();
-                if(prop.getAccessPropertyType() == InspectorProperty.TYPE.METHOD) {
-                    Method method = objectClass.getMethod(prop.getAccessName());
-                    collectorReference = (Map<CharSequence, Value>) method.invoke(resultObject);
-                } else if(prop.getAccessPropertyType() == InspectorProperty.TYPE.FIELD) {
-                    Field field = objectClass.getField(prop.getMutateName());
-                    collectorReference = (Map<CharSequence, Value>) field.get(resultObject);
+        for(Entry<CharSequence, Value> documentPropertyEntry : jsonObject.entrySet()) {
+            CharSequence key = documentPropertyEntry.getKey();
+            if(inspector.hasProperty(key.toString())) {
+                InspectorProperty inspectorProperty = inspector.getProperty(key.toString());
+                Value documentValue = documentPropertyEntry.getValue();
+                try {
+                    marshalDocumentToObject(objectClass, object, documentValue, inspectorProperty);
+                } catch(NoSuchMethodException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+                } catch(IllegalArgumentException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+                } catch(IllegalAccessException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+                } catch(InvocationTargetException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+                } catch(NoSuchFieldException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
                 }
+            } else if(hasCollector) {
+                collector.put(key, documentPropertyEntry.getValue());
+            }
+            if(inspector.hasInnerObject()) {
+                innerObjectCollector.put(key, documentPropertyEntry.getValue());
             }
+        }
 
-            for(MarshalerPropertyValue propertyValue : objectPropertyValues) {
-                if(propertyValue.getValue().isNull()) {
-                    // TODO: Handle Null
+        if(hasCollector) {
+            Map<CharSequence, Value> collectorReference = null;
+            InspectorProperty collectorProperty = inspector.getCollector();
+            if(collectorProperty.getAccessPropertyType() == InspectorProperty.TYPE.METHOD) {
+                try {
+                    Method method = objectClass.getMethod(collectorProperty.getAccessName());
+                    collectorReference = (Map<CharSequence, Value>) method.invoke(object);
+                } catch(IllegalAccessException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+                } catch(IllegalArgumentException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+                } catch(InvocationTargetException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+                } catch(NoSuchMethodException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+                } catch(SecurityException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+                }         
+            } else if(collectorProperty.getAccessPropertyType() == InspectorProperty.TYPE.FIELD) {
+                try {
+                    Field field = objectClass.getField(collectorProperty.getAccessName());
+                    collectorReference = (Map<CharSequence, Value>) field.get(object);
+                } catch(IllegalArgumentException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+                } catch(IllegalAccessException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+                } catch(NoSuchFieldException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
+                } catch(SecurityException ex) {
+                    Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
                 }
-                InspectorProperty property = propertyValue.getProperty();
-                if(property.getAccessPropertyType() == InspectorProperty.TYPE.METHOD) {
-                    Method method = objectClass.getMethod(property.getMutateName(), property.getMutateInputType());
-                    JavaType mutateType = JavaType.inspectObjectType(property.getMutateInputType());
-
-                    JSON.Array<Value> arrayJSON = null;
-
-                    switch(mutateType) {
-                        case BOOLEAN:
-                            method.invoke(resultObject, propertyValue.getValue().getBoolean());
-                            break;
-                        case BYTE:
-                            method.invoke(resultObject, propertyValue.getValue().getNumber().byteValue());
-                            break;
-                        case INTEGER:
-                            method.invoke(resultObject, propertyValue.getValue().getNumber().intValue());
-                            break;
-                        case SHORT:
-                            method.invoke(resultObject, propertyValue.getValue().getNumber().shortValue());
-                            break;
-                        case FLOAT:
-                            method.invoke(resultObject, propertyValue.getValue().getNumber().floatValue());
-                            break;
-                        case LONG:
-                            method.invoke(resultObject, propertyValue.getValue().getNumber().longValue());
-                            break;
-                        case DOUBLE:
-                            method.invoke(resultObject, propertyValue.getValue().getNumber().doubleValue());
-                            break;
-                        case STRING:
-                            method.invoke(resultObject, propertyValue.getValue().getString());
-                            break;
-                        case ENUM:
-                            method.invoke(resultObject, propertyValue.getValue().getString());
-                            break;
-                        case MAP:
-
-                            break;
-                        case LIST:
-
-                            break;
-                        case OBJECT:
-                            JSON.Object<CharSequence, Value> objectJSON = (JSON.Object<CharSequence, Value>) propertyValue.getValue();
-                            method.invoke(resultObject, marshalJSONDocumentObject(objectJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            method.invoke(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_BYTE:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            method.invoke(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_SHORT:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            method.invoke(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_INTEGER:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            method.invoke(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_FLOAT:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            method.invoke(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_DOUBLE:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            method.invoke(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_LONG:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            method.invoke(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_STRING:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            method.invoke(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_ENUM:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            method.invoke(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_LIST:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            method.invoke(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_MAP:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            method.invoke(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        default:
-
-                            break;
-                    }
-                } else if(property.getAccessPropertyType() == InspectorProperty.TYPE.FIELD) {
-                    Field field = objectClass.getField(propertyValue.getProperty().getMutateName());
-                    JavaType mutateType = JavaType.inspectObjectType(property.getMutateInputType());
-
-                    JSON.Array<Value> arrayJSON = null;
-
-                    switch(mutateType) {
-                        case BOOLEAN:
-                            field.set(resultObject, propertyValue.getValue().getBoolean());
-                            break;
-                        case BYTE:
-                            field.set(resultObject, propertyValue.getValue().getNumber().byteValue());
-                            break;
-                        case INTEGER:
-                            field.set(resultObject, propertyValue.getValue().getNumber().intValue());
-                            break;
-                        case SHORT:
-                            field.set(resultObject, propertyValue.getValue().getNumber().shortValue());
-                            break;
-                        case FLOAT:
-                            field.set(resultObject, propertyValue.getValue().getNumber().floatValue());
-                            break;
-                        case LONG:
-                            field.set(resultObject, propertyValue.getValue().getNumber().longValue());
-                            break;
-                        case DOUBLE:
-                            field.set(resultObject, propertyValue.getValue().getNumber().doubleValue());
-                            break;
-                        case STRING:
-                            field.set(resultObject, propertyValue.getValue().getString());
-                            break;
-                        case ENUM:
-
-                            break;
-                        case MAP:
-
-                            break;
-                        case LIST:
-
-                            break;
-                        case OBJECT:
-                            JSON.Object<CharSequence, Value> objectJSON = (JSON.Object<CharSequence, Value>) propertyValue.getValue();
-                            field.set(resultObject, marshalJSONDocumentObject(objectJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            field.set(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_BYTE:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            field.set(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_SHORT:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            field.set(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_INTEGER:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            field.set(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_FLOAT:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            field.set(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_DOUBLE:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            field.set(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_LONG:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            field.set(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_STRING:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            field.set(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_ENUM:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            field.set(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_LIST:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            field.set(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_MAP:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            field.set(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        case ARRAY_ARRAY:
-                            arrayJSON = (JSON.Array<Value>) propertyValue.getValue();
-                            field.set(resultObject, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
-                            break;
-                        default:
-                            break;
-                    }
+            } 
+            if(collectorReference != null) {
+                for(Entry<CharSequence, Value> collectorEntry: collector.entrySet()) {
+                    collectorReference.put(collectorEntry.getKey(), collectorEntry.getValue());
                 }
             }
-            if(hasCollector) {
-                for(MarshalerPropertyValue propertyValue : collectorPropertyValues) {
-                    collectorReference.put(propertyValue.getName(), propertyValue.getValue());
-                }
+        }
+        if(inspector.hasInnerObject()) {
+            Map<CharSequence, Value> innerObject = (Map<CharSequence, Value>) object;
+            for(Entry<CharSequence, Value> innerObjectEntry: innerObjectCollector.entrySet()) {
+                innerObject.put(innerObjectEntry.getKey(), innerObjectEntry.getValue());
             }
-        } catch(InstantiationException ex) {
-            Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
-        } catch(IllegalAccessException ex) {
-            Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
-        } catch(NoSuchFieldException ex) {
-            Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
-        } catch(NoSuchMethodException ex) {
-            Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
-        } catch(InvocationTargetException ex) {
-            Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
         }
-        return resultObject;
+        
+        if(inspector.hasInnerArray()) {
+        }
+
+        return object;
     }
 
     public Object marshalJSONDocument(InputStream stream, Class<?> objectClass) throws JSONMarshalerException {
         return array;
     }
 
-    /*
-     * public boolean[]
-     * marshalJSONDocumentIntegerArrayPrimitive(JSON.Array<Value> jsonArray,
-     * Class<?> objectClass) { int size = jsonArray.size(); boolean[] array =
-     * (boolean[]) Array.newInstance(objectClass.getComponentType(), size); for
-     * (int i = 0; i < size; i++) { Array.set(array, i,
-     * jsonArray.get(i).getNumber().intValue()); } return array; }
-     *
-     * public Boolean[] marshalJSONDocumentIntegerArray(JSON.Array<Value>
-     * jsonArray, Class<?> objectClass) { int size = jsonArray.size(); Boolean[]
-     * array = (Boolean[]) Array.newInstance(objectClass.getComponentType(),
-     * size); for (int i = 0; i < size; i++) { Array.set(array, i,
-     * jsonArray.get(i).getNumber().intValue()); } return array; }
-     *
-     *
-     * public int[] marshalJSONDocumentIntegerArrayPrimitive(JSON.Array<Value>
-     * jsonArray, Class<?> objectClass) { int size = jsonArray.size(); int[]
-     * array = (int[]) Array.newInstance(objectClass.getComponentType(), size);
-     * for (int i = 0; i < size; i++) { Array.set(array, i,
-     * jsonArray.get(i).getNumber().intValue()); } return array; }
-     *
-     * public Integer[] marshalJSONDocumentIntegerArray(JSON.Array<Value>
-     * jsonArray, Class<?> objectClass) { int size = jsonArray.size(); Integer[]
-     * array = (Integer[]) Array.newInstance(objectClass.getComponentType(),
-     * size); for (int i = 0; i < size; i++) { Array.set(array, i,
-     * jsonArray.get(i).getNumber().intValue()); } return array; }
-     */
+    public Map<?, ?> marshalJSONDocumentMap(InspectorProperty property, Value propertyValue) throws JSONMarshalerException {
+        
+        Class<?> mapType = property.getMutateInputType();
+        
+        return null;
+    }
+
+    private void marshalDocumentToObject(Class<?> objectClass, Object object, Value propertyValue, InspectorProperty property) throws NoSuchMethodException, IllegalArgumentException, IllegalAccessException, JSONMarshalerException, InvocationTargetException, NoSuchFieldException {
+        JavaType mutateType = JavaType.inspectObjectType(property.getMutateInputType());
+        if(property.getAccessPropertyType() == InspectorProperty.TYPE.METHOD) {
+            Method method = objectClass.getMethod(property.getMutateName(), property.getMutateInputType());
+            JSON.Array<Value> arrayJSON;
+            switch(mutateType) {
+                case BOOLEAN:
+                    method.invoke(object, propertyValue.getBoolean());
+                    break;
+                case BYTE:
+                    method.invoke(object, propertyValue.getNumber().byteValue());
+                    break;
+                case INTEGER:
+                    method.invoke(object, propertyValue.getNumber().intValue());
+                    break;
+                case SHORT:
+                    method.invoke(object, propertyValue.getNumber().shortValue());
+                    break;
+                case FLOAT:
+                    method.invoke(object, propertyValue.getNumber().floatValue());
+                    break;
+                case LONG:
+                    method.invoke(object, propertyValue.getNumber().longValue());
+                    break;
+                case DOUBLE:
+                    method.invoke(object, propertyValue.getNumber().doubleValue());
+                    break;
+                case STRING:
+                    method.invoke(object, propertyValue.getString());
+                    break;
+                case ENUM:
+                    method.invoke(object, propertyValue.getString());
+                    break;
+                case MAP:
+                   //JSON.Object<CharSequence, Value> mapJSON = (JSON.Object<CharSequence, Value>) propertyValue;
+                    
+                    method.invoke(object, marshalJSONDocumentMap(property, propertyValue));
+                    break;
+                case LIST:
+
+                    break;
+                case OBJECT:
+                    JSON.Object<CharSequence, Value> objectJSON = (JSON.Object<CharSequence, Value>) propertyValue;
+                    method.invoke(object, marshalJSONDocumentObject(objectJSON, property.getMutateInputType()));
+                    break;
+                case ARRAY:
+                case ARRAY_BYTE:
+                case ARRAY_SHORT:
+                case ARRAY_INTEGER:
+                case ARRAY_FLOAT:
+                case ARRAY_DOUBLE:
+                case ARRAY_LONG:
+                case ARRAY_STRING:
+                case ARRAY_ENUM:
+                case ARRAY_LIST:
+                case ARRAY_MAP:
+                case ARRAY_ARRAY:
+                    arrayJSON = (JSON.Array<Value>) propertyValue;
+                    method.invoke(object, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
+                    break;
+                default:
+
+                    break;
+            }
+        } else if(property.getAccessPropertyType() == InspectorProperty.TYPE.FIELD) {
+            Field field = objectClass.getField(property.getMutateName());
+            JSON.Array<Value> arrayJSON;
+            switch(mutateType) {
+                case BOOLEAN:
+                    field.set(object, propertyValue.getBoolean());
+                    break;
+                case BYTE:
+                    field.set(object, propertyValue.getNumber().byteValue());
+                    break;
+                case INTEGER:
+                    field.set(object, propertyValue.getNumber().intValue());
+                    break;
+                case SHORT:
+                    field.set(object, propertyValue.getNumber().shortValue());
+                    break;
+                case FLOAT:
+                    field.set(object, propertyValue.getNumber().floatValue());
+                    break;
+                case LONG:
+                    field.set(object, propertyValue.getNumber().longValue());
+                    break;
+                case DOUBLE:
+                    field.set(object, propertyValue.getNumber().doubleValue());
+                    break;
+                case STRING:
+                    field.set(object, propertyValue.getString());
+                    break;
+                case ENUM:
+                    field.set(object, propertyValue.getString());
+                    break;
+                case MAP:
+                    JSON.Object<CharSequence, Value> mapJSON = (JSON.Object<CharSequence, Value>) propertyValue;
+                    field.set(object, marshalJSONDocumentMap(property, propertyValue));
+                    break;
+                case LIST:
+
+                    break;
+                case OBJECT:
+                    JSON.Object<CharSequence, Value> objectJSON = (JSON.Object<CharSequence, Value>) propertyValue;
+                    field.set(object, marshalJSONDocumentObject(objectJSON, property.getMutateInputType()));
+                    break;
+                case ARRAY:
+                case ARRAY_BYTE:
+                case ARRAY_SHORT:
+                case ARRAY_INTEGER:
+                case ARRAY_FLOAT:
+                case ARRAY_DOUBLE:
+                case ARRAY_LONG:
+                case ARRAY_STRING:
+                case ARRAY_ENUM:
+                case ARRAY_LIST:
+                case ARRAY_MAP:
+                case ARRAY_ARRAY:
+                    arrayJSON = (JSON.Array<Value>) propertyValue;
+                    field.set(object, marshalJSONDocumentArray(arrayJSON, property.getMutateInputType()));
+                    break;
+                default:
+                    break;
+            }
+        }
+    }
+    
     public static class MarshalerPropertyValue {
 
         String name;

File src/main/java/cc/plural/jsonij/marshal/JSONMarshaler.java

+/**
+ * Copyright (C) 2010-2011 J.W.Marsden
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ **/
+package cc.plural.jsonij.marshal;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import cc.plural.jsonij.JSON;
+import cc.plural.jsonij.Value;
+import cc.plural.jsonij.parser.ParserException;
+
+/**
+ *
+ * @author jmarsden@plural.cc
+ */
+public class JSONMarshaler {
+
+    protected static final JavaMarshaler JAVA_MARSHALLER;
+    protected static final JSONDocumentMarshaler JSON_DOCUMENT_MARSHALER;
+
+    public static boolean ALWAYS_USE_INNER_PROPERTY;
+    public static String INNER_ARRAY_PROPERTY;
+    public static String INNER_OBJECT_PROPERTY;
+    
+    static {
+        JAVA_MARSHALLER = new JavaMarshaler();
+        JSON_DOCUMENT_MARSHALER = new JSONDocumentMarshaler();
+        ALWAYS_USE_INNER_PROPERTY = false;
+        INNER_ARRAY_PROPERTY = "$innerArray";
+        INNER_OBJECT_PROPERTY = "$innerObject";
+    }
+
+    public static JSON marshalObject(Object o) {
+        Value mashaledObject = JAVA_MARSHALLER.marshalObject(o);
+        return new JSON(mashaledObject);
+    }
+
+    public static JSON marshalObject(boolean[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(Boolean[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(int[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(Integer[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(char[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(Character[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(double[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(Double[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(float[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(Float[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(short[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(Short[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(long[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(Long[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(String[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+
+    public static JSON marshalObject(Object[] a) {
+        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
+        return new JSON(marshaledArray);
+    }
+    
+    public static Object marshalJSON(String json, Class<?> c) throws JSONMarshalerException, IOException, ParserException {
+        Object marshaledObject = JSON_DOCUMENT_MARSHALER.marshalJSONDocument(JSON.parse(json), c);
+        return marshaledObject;
+    }
+    
+    public static Object marshalJSON(JSON json, Class<?> c) throws JSONMarshalerException {
+        Object marshaledObject = JSON_DOCUMENT_MARSHALER.marshalJSONDocument(json, c);
+        return marshaledObject;
+    }
+    
+    public static Object marshalJSON(Value value, Class<?> c) throws JSONMarshalerException {
+        Object marshaledObject = JSON_DOCUMENT_MARSHALER.marshalJSONDocument(value, c);
+        return marshaledObject;
+    }
+    
+    public static Object marshalJSON(InputStream stream, Class<?> c) throws JSONMarshalerException {
+        Object marshaledObject = JSON_DOCUMENT_MARSHALER.marshalJSONDocument(stream, c);
+        return marshaledObject;
+    }
+}

File src/main/java/cc/plural/jsonij/marshal/JavaMarshaler.java

     }
 
     protected Value marshalJavaList(Object o, CycleDetector cycleDetector) {
-        Value value = null;
-        List<?> marshaledList = (List<?>) o;
-        if(marshaledList != null) {
+        Value value;
+        if(o != null) {
+            List<?> marshaledList = (List<?>) o;
             JSON.Array<Value> marshaledArray = new JSON.Array<Value>();
             Iterator<?> marshaledListIterator = marshaledList.listIterator();
             Object listItem = null;
     }
 
     protected Value marshalJavaMap(Object o, CycleDetector cycleDetector) {
-        Value value = null;
-        Map<?, ?> marshaledMap = (Map<?, ?>) o;
-        if(marshaledMap != null) {
+        Value value;
+        if(o != null) {
+            Map<?, ?> marshaledMap = (Map<?, ?>) o;
             JSON.Object<JSON.String, Value> marshaledObject = new JSON.Object<JSON.String, Value>();
             Iterator<?> keySetIterator = marshaledMap.keySet().iterator();
             while(keySetIterator.hasNext()) {

File src/main/java/cc/plural/jsonij/marshal/JavaObjectMarshaler.java

 
         HashMap<String, Value> valueObject = new HashMap<String, Value>();
         InspectorProperty[] properties = inspector.getProperties();
-        String name = null;
-        Value value = null;
+        String name;
+        Value value;
         int propCount = 0;
         for(InspectorProperty property : properties) {
             if(!property.hasAccessor()) {
             valueObject.put(name, value);
         }
         if(inspector.hasInnerArray()) {
-            if(propCount > 0) {
-                valueObject.put("innerArray", marshaler.marshalJavaList(o, cycleDetector));
+            if(JSONMarshaler.ALWAYS_USE_INNER_PROPERTY || propCount > 0) {
+                valueObject.put(JSONMarshaler.INNER_ARRAY_PROPERTY, marshaler.marshalJavaList(o, cycleDetector));
             } else {
                 return marshaler.marshalJavaList(o, cycleDetector);
             }
         }
         if(inspector.hasInnerObject()) {
-            if(propCount > 0) {
-                valueObject.put("innerObject", marshaler.marshalJavaMap(o, cycleDetector));
+            if(JSONMarshaler.ALWAYS_USE_INNER_PROPERTY || propCount > 0) {
+                valueObject.put(JSONMarshaler.INNER_OBJECT_PROPERTY, marshaler.marshalJavaMap(o, cycleDetector));
             } else {
                 return marshaler.marshalJavaMap(o, cycleDetector);
             }
     }
 
     protected Value marshalObjectFieldValue(Field field, Object o, CycleDetector cycleDetector) throws IllegalArgumentException, IllegalAccessException {
-        Value value = null;
+        Value value;
         Object marshaledObject = field.get(o);
         if(marshaledObject == null) {
             value = null;

File src/main/java/cc/plural/jsonij/marshal/JavaType.java

             type = getArrayType(c);
             return type;
         }
-        if(type == null) {
-            if(c == List.class) {
-                type = JavaType.LIST;
-                type.setPrimitive(false);
-                return type;
-            } else {
-                // Test if Object is a List
-                Class<?>[] interfaces = c.getInterfaces();
-                for(int i = 0; i < Array.getLength(interfaces); i++) {
-                    if(interfaces[i] == List.class) {
-                        type = JavaType.LIST;
-                        type.setPrimitive(false);
-                        return type;
-                    }
-                }
-            }
-            Class<?>[] interfaces = c.getInterfaces();
-            // Test if super classes are List
-            Class<?> parent = c.getSuperclass();
-            if(parent != null) {
-                do {
-                    interfaces = parent.getInterfaces();
-                    for(int i = 0; i < Array.getLength(interfaces); i++) {
-                        if(interfaces[i] == List.class) {
-                            type = JavaType.LIST;
-                            return type;
-                        }
-                    }
-                } while((parent = parent.getSuperclass()) != null);
-            }
+        
+        if(c == List.class) {
+            return JavaType.LIST;
         }
-        if(type == null) {
-            if(c == Map.class) {
-                type = JavaType.MAP;
-                type.setPrimitive(false);
-                return type;
-            } else {
-                // Test if Object is a List
-                Class<?>[] interfaces = c.getInterfaces();
-                for(int i = 0; i < Array.getLength(interfaces); i++) {
-                    if(interfaces[i] == Map.class) {
-                        type = JavaType.MAP;
-                        type.setPrimitive(false);
-                        return type;
-                    }
+        if(c == Map.class) {
+            return JavaType.MAP;
+        }
+        
+        Class<?>[] interfaces;
+        Class<?> currentClass = c;
+        
+        do {
+            interfaces = currentClass.getInterfaces();
+            for(int i = 0; i < Array.getLength(interfaces); i++) {
+                if(interfaces[i] == List.class) {
+                    type = JavaType.LIST;
+                } else if(interfaces[i] == Map.class) {
+                    type = JavaType.MAP;
                 }
             }
-            Class<?>[] interfaces = c.getInterfaces();
-            Class<?> parent = c.getSuperclass();
-            if(parent != null) {
-                do {
-                    interfaces = parent.getInterfaces();
-                    for(int i = 0; i < Array.getLength(interfaces); i++) {
-                        if(interfaces[i] == Map.class) {
-                            type = JavaType.MAP;
-                            return type;
-                        }
-                    }
-                } while((parent = parent.getSuperclass()) != null);
-            }
-        }
-        if(c.getComponentType() ==  Class.class) {
+        } while((currentClass = currentClass.getSuperclass()) != null);
+
+        if((JSONMarshaler.ALWAYS_USE_INNER_PROPERTY && (type!=null)) || isObjectType(c)) {
+            type = JavaType.OBJECT;
+            type.setPrimitive(false);
+            return type;
+        } 
+        if(c.getComponentType() == Class.class) {
             type = JavaType.OBJECT;
             return type;
-        }
-         
-        if(type == null) {
-            if(isObjectType(c)) {
-                type = JavaType.OBJECT;
-                type.setPrimitive(false);
-                return type;
-            }
-            
         }
         if(type != null) {
             return type;
     public static boolean isObjectType(Class<?> objectClass) {
         Inspector inspector = getInstpector(objectClass);
         InspectorProperty[] properties = inspector.getProperties();
-        if((properties != null && Array.getLength(properties) > 0) || inspector.hasInnerArray() || inspector.hasInnerObject()) {
+        if((properties != null && Array.getLength(properties) > 0)/* || inspector.hasInnerArray() || inspector.hasInnerObject() */) {
             return true;
         }
         return false;

File src/main/java/cc/plural/jsonij/marshal/codec/ClassJSONCodec.java

 
     @Override
     public ClassJSONCodec<C> createInstance() {
-	return new ClassJSONCodec<C>();
+        return new ClassJSONCodec<C>();
     }
 
     @Override
     public Value encode(C c) {
-	return new JSON.String(c.getName());
+        return new JSON.String(c.getName());
     }
 
     @Override
     public C decode(Value value) {
-	Class<?> c = null;
-	try {
-	    c = Class.forName(value.getString());
-	} catch (ClassNotFoundException ex) {
-	    throw new UnsupportedOperationException("Incorrect Value Type." + ex);
-	}
-	return (C) c;
+        Class<?> c = null;
+        try {
+            c = Class.forName(value.getString());
+        } catch(ClassNotFoundException ex) {
+            throw new UnsupportedOperationException("Incorrect Value Type." + ex);
+        }
+        return (C) c;
     }
 }

File src/test/java/cc/plural/jsonij/marshal/HandlerConfig.java

-/**
- * Copyright (C) 2012 J.W.Marsden <jmarsden@plural.cc>
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package cc.plural.jsonij.marshal;
-
-import java.util.HashMap;
-
-/**
- *
- * @author jmarsden
- */
-public class HandlerConfig<String, Class> extends HashMap<String, Class> {
-   
-}

File src/test/java/cc/plural/jsonij/marshal/JSONDocumentMarshalerTest.java

 package cc.plural.jsonij.marshal;
 
 import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
 import cc.plural.jsonij.JSON;
-import cc.plural.jsonij.JSONMarshaler;
 import cc.plural.jsonij.marshal.codec.ClassJSONCodec;
+import cc.plural.jsonij.marshal.helpers.HandlerConfiguration;
 import cc.plural.jsonij.marshal.helpers.JSONObject;
 import cc.plural.jsonij.parser.ParserException;
 import static org.junit.Assert.assertEquals;
     @Test
     public void testMarshalHandlerClass() throws JSONMarshalerException, IOException, ParserException, IllegalAccessException, InstantiationException, ClassNotFoundException {
         System.out.println("testMarshalHandlerClass");
-        HandlerConfig<String, Class<?>> config = new HandlerConfig<String, Class<?>>();
-        config.put("http", Handler.class);
-        config.put("ftp", Handler.class);
-
+        HandlerConfiguration config = new HandlerConfiguration();
+        Map<String, Class<?>> handlers = new HashMap<String, Class<?>>();
+        handlers.put("http", Handler.class);
+        handlers.put("ftp", Handler.class);
+        config.setHandlers(handlers);
+        
         JavaObjectMarshaler.registerCodec(ClassJSONCodec.class);
         JSON outputJSON = JSONMarshaler.marshalObject(config);
         System.out.println("Output JSON:" + outputJSON);
         Handler handler = (Handler) c.newInstance();
         assertNotNull(handler);
 
-        HandlerConfig<String, Class<?>> reload = (HandlerConfig<String, Class<?>>) JSONMarshaler.marshalJSON(outputJSON, config.getClass());
+        HandlerConfiguration reload = (HandlerConfiguration) JSONMarshaler.marshalJSON(outputJSON, config.getClass());
     }
 
     public static class Handler {

File src/test/java/cc/plural/jsonij/marshal/MapInnerObjectMarshalTests.java

+/*
+ * Copyright 2012 jmarsden.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cc.plural.jsonij.marshal;
+
+import java.io.IOException;
+
+import cc.plural.jsonij.JSON;
+import cc.plural.jsonij.marshal.helpers.ListTypeNoProps;
+import cc.plural.jsonij.marshal.helpers.MapTypeNoProps;
+import cc.plural.jsonij.marshal.helpers.MapTypeProps;
+import cc.plural.jsonij.parser.ParserException;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ *
+ * @author jmarsden
+ */
+public class MapInnerObjectMarshalTests {
+
+    public MapInnerObjectMarshalTests() {
+    }
+
+    @Test
+    public void testMapNoPropsPrint() throws ParserException, IOException {
+        System.out.println("testMapNoPropsPrint");
+        MapTypeNoProps<String, String> map1 = new MapTypeNoProps<String, String>();
+        map1.put("key1", "value1");
+        map1.put("key2", "value2");
+
+        JSONMarshaler.ALWAYS_USE_INNER_PROPERTY = false;
+        JSON json1 = JSONMarshaler.marshalObject(map1);
+        System.out.println(json1.toJSON());
+        
+        assertTrue(json1.equals(JSON.parse("{\"key2\":\"value2\",\"key1\":\"value1\"}")));
+
+        JSONMarshaler.ALWAYS_USE_INNER_PROPERTY = true;
+        JSON json2 = JSONMarshaler.marshalObject(map1);
+        System.out.println(json2.toJSON());
+        
+        assertTrue(json2.equals(JSON.parse("{\"$innerObject\":{\"key2\":\"value2\",\"key1\":\"value1\"}}")));
+    }
+
+    @Test
+    public void testMapPropsPrint() throws ParserException, IOException {
+        System.out.println("testMapPropsPrint");
+        MapTypeProps<String, String> map1 = new MapTypeProps<String, String>();
+        map1.put("key1", "value1");
+        map1.put("key2", "value2");
+        map1.setPrivateInt(55);
+        map1.publicString = "rah";
+
+        JSONMarshaler.ALWAYS_USE_INNER_PROPERTY = false;
+        JSON json1 = JSONMarshaler.marshalObject(map1);
+        System.out.println(json1.toJSON());
+
+        assertTrue(json1.equals(JSON.parse("{\"$innerObject\":{\"key2\":\"value2\",\"key1\":\"value1\"},\"privateInt\":55,\"publicString\":\"rah\"}")));
+        
+        JSONMarshaler.ALWAYS_USE_INNER_PROPERTY = true;
+        JSON json2 = JSONMarshaler.marshalObject(map1);
+        System.out.println(json2.toJSON());
+        
+        assertTrue(json2.equals(JSON.parse("{\"$innerObject\":{\"key2\":\"value2\",\"key1\":\"value1\"},\"privateInt\":55,\"publicString\":\"rah\"}")));
+    }
+    
+    @Test
+    public void testListNoPropsPrint() throws ParserException, IOException {
+        System.out.println("testListNoPropsPrint");
+        ListTypeNoProps<String> list = new ListTypeNoProps<String>();
+        list.add("value1");
+        list.add("value2");
+        list.add("value3");
+        
+        JSONMarshaler.ALWAYS_USE_INNER_PROPERTY = false;
+        JSON json1 = JSONMarshaler.marshalObject(list);
+        System.out.println(json1.toJSON());
+
+        assertTrue(json1.equals(JSON.parse("[\"value1\",\"value2\",\"value3\"]")));
+        
+        JSONMarshaler.ALWAYS_USE_INNER_PROPERTY = true;
+        JSON json2 = JSONMarshaler.marshalObject(list);
+        System.out.println(json2.toJSON());
+        
+        assertTrue(json2.equals(JSON.parse("{\"$innerArray\":[\"value1\",\"value2\",\"value3\"]}")));
+    }
+}

File src/test/java/cc/plural/jsonij/marshal/NebulousServerTest.java

 import java.util.HashMap;
 
 import cc.plural.jsonij.JSON;
-import cc.plural.jsonij.JSONMarshaler;
 import cc.plural.jsonij.Value;
 import cc.plural.jsonij.marshal.annotation.JSONCollector;
+import cc.plural.jsonij.marshal.helpers.MapTypeNoProps;
 import cc.plural.jsonij.parser.ParserException;
 import org.junit.Test;
 import static org.junit.Assert.*;
 
     @Test
     public void testMapDetection() throws JSONMarshalerException, IOException, ParserException {
-        boolean isMap = Inspector.isMapType(HandlerConfig.class);
+        boolean isMap = Inspector.isMapType(MapTypeNoProps.class);
         assertEquals(true, isMap);
         
         isMap = Inspector.isMapType(String.class);

File src/test/java/cc/plural/jsonij/marshal/ObjectWithMapPropetyMarshalTests.java

+/*
+ * Copyright 2012 jmarsden.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cc.plural.jsonij.marshal;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.TypeVariable;
+
+import cc.plural.jsonij.JSON;
+import cc.plural.jsonij.marshal.helpers.ObjectWithMapObjectObject;
+import cc.plural.jsonij.parser.ParserException;
+import org.junit.Test;
+
+/**
+ *
+ * @author jmarsden
+ */
+public class ObjectWithMapPropetyMarshalTests {
+
+    @Test
+    public void testReflect() throws ParserException, IOException, NoSuchMethodException, NoSuchFieldException {
+        Class<?> clazz = ObjectWithMapObjectObject.class;
+        Method method = clazz.getMethod("getMap");
+        java.lang.reflect.Type returnType = method.getGenericReturnType();
+        
+        TypeVariable<Method>[] typeArray = method.getTypeParameters();
+        
+        Field field = clazz.getField("map");
+        java.lang.reflect.Type type = field.getGenericType();  
+    }
+    
+    @Test
+    public void testObjectMapProperty() throws ParserException, IOException {
+        System.out.println("testObjectMapProperty");
+        
+        String jsonString = "{\"map\":{\"1\":\"One\",\"2\":\"Two\"}}";
+        JSON json = JSON.parse(jsonString);
+        
+        //ObjectWithMapObjectObject map = (ObjectWithMapObjectObject) JSONMarshaler.marshalJSON(json, ObjectWithMapObjectObject.class);
+        
+        //assertEquals(map.getMap().size(), 2);
+    }
+}

File src/test/java/cc/plural/jsonij/marshal/helpers/HandlerConfiguration.java

+/**
+ * Copyright (C) 2012 J.W.Marsden <jmarsden@plural.cc>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package cc.plural.jsonij.marshal.helpers;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * @author jmarsden
+ */
+public class HandlerConfiguration {
+
+    Map<String, Class<?>> handlers;
+
+    public HandlerConfiguration() {
+        handlers = new HashMap<String, Class<?>>();
+    }
+
+    public Map<String, Class<?>> getHandlers() {
+        return handlers;
+    }
+
+    public void setHandlers(Map<String, Class<?>> handlers) {
+        this.handlers = handlers;
+    }
+}

File src/test/java/cc/plural/jsonij/marshal/helpers/JSONObject.java

 package cc.plural.jsonij.marshal.helpers;
 
-import cc.plural.jsonij.marshal.helpers.JSONObject2;
-
 public class JSONObject {
 
     public int rah;

File src/test/java/cc/plural/jsonij/marshal/helpers/ListTypeNoProps.java

+/*
+ * Copyright 2012 jmarsden.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cc.plural.jsonij.marshal.helpers;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * @author jmarsden
+ */
+public class ListTypeNoProps<V> extends ArrayList<V> {
+    
+}

File src/test/java/cc/plural/jsonij/marshal/helpers/ListTypeProps.java

+/*
+ * Copyright 2012 jmarsden.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cc.plural.jsonij.marshal.helpers;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * @author jmarsden
+ */
+public class ListTypeProps<V> extends ArrayList<V> {
+
+    public String publicString;
+
+    private int privateInt;
+
+    public int getPrivateInt() {
+        return privateInt;
+    }
+
+    public void setPrivateInt(int privateInt) {
+        this.privateInt = privateInt;
+    }
+}

File src/test/java/cc/plural/jsonij/marshal/helpers/MapTypeNoProps.java

+/*
+ * Copyright 2012 jmarsden.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cc.plural.jsonij.marshal.helpers;
+
+import java.util.HashMap;
+
+/**
+ *
+ * @author jmarsden
+ */
+public class MapTypeNoProps<K,V> extends HashMap<K,V> {
+    
+}

File src/test/java/cc/plural/jsonij/marshal/helpers/MapTypeProps.java

+/*
+ * Copyright 2012 jmarsden.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cc.plural.jsonij.marshal.helpers;
+
+import java.util.HashMap;
+
+/**
+ *
+ * @author jmarsden
+ */
+public class MapTypeProps <K,V> extends HashMap<K,V> {
+    
+    public String publicString;
+    
+    private int privateInt;
+
+    public int getPrivateInt() {
+        return privateInt;
+    }
+
+    public void setPrivateInt(int privateInt) {
+        this.privateInt = privateInt;
+    }
+}

File src/test/java/cc/plural/jsonij/marshal/helpers/ObjectWithMapObjectObject.java

+/*
+ * Copyright 2012 jmarsden.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cc.plural.jsonij.marshal.helpers;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * @author jmarsden
+ */
+public class ObjectWithMapObjectObject {
+
+    private Map map;
+
+    public ObjectWithMapObjectObject() {
+        map = new HashMap();
+    }
+
+    public Map getMap() {
+        return map;
+    }
+
+    public void setMap(Map map) {
+        this.map = map;
+    }
+}

File src/test/java/cc/plural/jsonij/marshal/helpers/ObjectWithMapStringString.java

+/*
+ * Copyright 2012 jmarsden.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cc.plural.jsonij.marshal.helpers;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * @author jmarsden
+ */
+public class ObjectWithMapStringString {
+
+    public Map<String, String> map;
+
+    public ObjectWithMapStringString() {
+        map = new HashMap<String, String>();
+    }
+
+    public Map<String, String> getMap() {
+        return map;
+    }
+
+    public void setMap(Map<String, String> map) {
+        this.map = map;
+    }
+}

File src/test/java/jsonij/legacy/marshal/InspectorTest.java

 import org.junit.Test;
 
 import cc.plural.jsonij.JSON;
-import cc.plural.jsonij.JSONMarshaler;
+import cc.plural.jsonij.marshal.JSONMarshaler;
 import cc.plural.jsonij.marshal.Inspector;
 import cc.plural.jsonij.marshal.InspectorProperty;
 import cc.plural.jsonij.marshal.annotation.JSONAccessor;

File src/test/java/jsonij/legacy/marshal/JSONMarshalerTest.java

 import org.junit.Test;
 
 import cc.plural.jsonij.JSON;
-import cc.plural.jsonij.JSONMarshaler;
+import cc.plural.jsonij.marshal.JSONMarshaler;
 import cc.plural.jsonij.marshal.JavaObjectMarshaler;
 import cc.plural.jsonij.marshal.annotation.JSONAccessor;
 import cc.plural.jsonij.marshal.annotation.JSONIgnore;