private void processValue ( JsonToken valueToken , JsonParser parser , JsonGenerator jgen ) throws IOException { if ( valueToken . isBoolean ( ) ) { jgen . writeBoolean ( parser . getBooleanValue ( ) ) ; } else if ( valueToken . isNumeric ( ) ) { if ( parser . getNumberType ( ) == JsonParser . NumberType . INT ) { jgen . writeNumber ( parser . getIntValue ( ) ) ; } else if ( parser . getNumberType ( ) == JsonParser . NumberType . DOUBLE ) { jgen . writeNumber ( parser . getDoubleValue ( ) ) ; } else if ( parser . getNumberType ( ) == JsonParser . NumberType . FLOAT ) { jgen . writeNumber ( parser . getFloatValue ( ) ) ; } else if ( parser . getNumberType ( ) == JsonParser . NumberType . LONG ) { jgen . writeNumber ( parser . getLongValue ( ) ) ; } else if ( parser . getNumberType ( ) == JsonParser . NumberType . BIG_DECIMAL ) { jgen . writeNumber ( parser . getDecimalValue ( ) ) ; } else if ( parser . getNumberType ( ) == JsonParser . NumberType . BIG_INTEGER ) { jgen . writeNumber ( parser . getBigIntegerValue ( ) ) ; } else { LOGGER . error ( "Found unsupported numeric value with name {}." , parser . getCurrentName ( ) ) ; throw new RuntimeException ( "Found unsupported numeric value with name " + parser . getCurrentName ( ) ) ; } } else if ( valueToken . id ( ) == JsonTokenId . ID_STRING ) { jgen . writeString ( parser . getText ( ) ) ; } else { // Something bad just happened. Probably an unsupported type. LOGGER . error ( "Found unsupported value type {} for name {}." , valueToken . id ( ) , parser . getCurrentName ( ) ) ; throw new RuntimeException ( "Found unsupported value type " + valueToken . id ( ) + " for name " + parser . getCurrentName ( ) ) ; } }
Uses a JsonToken + JsonParser to determine how to write a value to the JsonGenerator .