private static void selectJsonRow ( CqlSession session ) { // Reading the whole row as a JSON object Statement stmt = selectFrom ( "examples" , "json_jsr353_row" ) . json ( ) . all ( ) . whereColumn ( "id" ) . in ( literal ( 1 ) , literal ( 2 ) ) . build ( ) ; ResultSet rows = session . execute ( stmt ) ; for ( Row row : rows ) { // SELECT JSON returns only one column for each row, of type VARCHAR, // containing the row as a JSON payload. // Note that the codec requires that the type passed to the get() method // be always JsonStructure, and not a subclass of it, such as JsonObject, // hence the need to downcast to JsonObject manually JsonObject user = ( JsonObject ) row . get ( 0 , JsonStructure . class ) ; System . out . printf ( "Retrieved user: %s%n" , user ) ; } }
Retrieving User instances from table rows using SELECT JSON