private static String toJsonCollection ( Collection objects ) { Iterator iterator = objects . iterator ( ) ; if ( ! iterator . hasNext ( ) ) { return "" ; } final Object first = iterator . next ( ) ; if ( ! iterator . hasNext ( ) ) { return toJson ( first ) ; } final StringBuilder buf = new StringBuilder ( ) ; if ( first != null ) { buf . append ( toJson ( first ) ) ; } while ( iterator . hasNext ( ) ) { buf . append ( ' ' ) ; final Object obj = iterator . next ( ) ; if ( obj != null ) { buf . append ( toJson ( obj ) ) ; } } return buf . toString ( ) ; }
Serializes a collection of objects into its JSON representation .