public Serializer writeArray ( JSONArray value ) throws IOException { if ( null == value ) return writeNull ( ) ; // write header writeRawString ( "[" ) ; indentPush ( ) ; for ( Iterator iter = value . iterator ( ) ; iter . hasNext ( ) ; ) { Object element = iter . next ( ) ; if ( ! JSONObject . isValidObject ( element ) ) throw new IOException ( "attempting to serialize array with an invalid element: '" + value + "'" ) ; newLine ( ) ; indent ( ) ; write ( element ) ; if ( iter . hasNext ( ) ) writeRawString ( "," ) ; } // write trailer indentPop ( ) ; newLine ( ) ; indent ( ) ; writeRawString ( "]" ) ; return this ; }
Method to write a JSON array out to the stream .