private static void generateJson ( CellScanner cellScanner , Function < Bytes , String > encoder , PrintStream out ) throws JsonIOException { Gson gson = new GsonBuilder ( ) . serializeNulls ( ) . setDateFormat ( DateFormat . LONG ) . setFieldNamingPolicy ( FieldNamingPolicy . LOWER_CASE_WITH_UNDERSCORES ) . setVersion ( 1.0 ) . create ( ) ; Map < String , String > json = new LinkedHashMap <> ( ) ; for ( RowColumnValue rcv : cellScanner ) { json . put ( FLUO_ROW , encoder . apply ( rcv . getRow ( ) ) ) ; json . put ( FLUO_COLUMN_FAMILY , encoder . apply ( rcv . getColumn ( ) . getFamily ( ) ) ) ; json . put ( FLUO_COLUMN_QUALIFIER , encoder . apply ( rcv . getColumn ( ) . getQualifier ( ) ) ) ; json . put ( FLUO_COLUMN_VISIBILITY , encoder . apply ( rcv . getColumn ( ) . getVisibility ( ) ) ) ; json . put ( FLUO_VALUE , encoder . apply ( rcv . getValue ( ) ) ) ; gson . toJson ( json , out ) ; out . append ( "\n" ) ; if ( out . checkError ( ) ) { break ; } } out . flush ( ) ; }
Generate JSON format as result of the scan .