public static Cells getCellFromJson ( LinkedMapWritable jsonObject , String tableName ) throws IllegalAccessException , InstantiationException , InvocationTargetException , NoSuchMethodException { Cells cells = tableName != null ? new Cells ( tableName ) : new Cells ( ) ; Set < Map . Entry < Writable , Writable > > entryJson = jsonObject . entrySet ( ) ; for ( Map . Entry < Writable , Writable > entry : entryJson ) { if ( LinkedMapWritable . class . isAssignableFrom ( entry . getValue ( ) . getClass ( ) ) ) { Cells innerCells = getCellFromJson ( ( LinkedMapWritable ) entry . getValue ( ) , null ) ; cells . add ( Cell . create ( entry . getKey ( ) . toString ( ) , innerCells ) ) ; } else if ( ArrayWritable . class . isAssignableFrom ( entry . getValue ( ) . getClass ( ) ) ) { Writable [ ] writetable = ( ( ArrayWritable ) entry . getValue ( ) ) . get ( ) ; List innerCell = new ArrayList <> ( ) ; for ( int i = 0 ; i < writetable . length ; i ++ ) { if ( writetable [ i ] instanceof LinkedMapWritable ) { innerCell . add ( getCellFromJson ( ( LinkedMapWritable ) writetable [ i ] , null ) ) ; } else { innerCell . add ( getObjectFromWritable ( entry . getValue ( ) ) ) ; } } cells . add ( Cell . create ( entry . getKey ( ) . toString ( ) , innerCell ) ) ; } else { cells . add ( Cell . create ( entry . getKey ( ) . toString ( ) , getObjectFromWritable ( entry . getValue ( ) ) ) ) ; } } return cells ; }
converts from JSONObject to cell class