class ObjectBuilder {

    public static Object createArray(Class<?> aClass, JsonValue jsonArray) throws JsonException {
        if (jsonArray == null || jsonArray.isNull()) {
            return null;
        }
        Class<?> componentType = aClass.getComponentType();
        Object array = Array.newInstance(componentType, jsonArray.size());
        Iterator<JsonValue> values = jsonArray.getElements();
        int i = 0;

        if (componentType.isArray()) {
            if (isKnownType(componentType)) {
                while (values.hasNext()) {
                    Array.set(array, i++, createObjectKnownTypes(componentType, values.next()));
                }
            } else {
                while (values.hasNext()) {
                    Array.set(array, i++, createArray(componentType, values.next()));
                }
            }
        } else {
            if (isKnownType(componentType)) {
                while (values.hasNext()) {
                    Array.set(array, i++, createObjectKnownTypes(componentType, values.next()));
                }
            } else {
                while (values.hasNext()) {
                    Array.set(array, i++, createObject(componentType, values.next()));
                }
            }
        }
        return array;
    }

    private  ObjectBuilder();

}