json = new JSONArray();
((JSONArray)json).addAll( (Collection)model );
}
else if ( model instanceof Closure ) {
Closure closure = (Closure)model;
closure.setDelegate( new JsonGroovyBuilder() );
json = (JSON)closure.call();
}
else if ( model instanceof String || model instanceof GString )
json = model; // assume string is valid JSON already.
else json = JSONObject.fromObject( model ); // Assume object is a JavaBean