// sanity check for null first:
if (fromValue == null) return null;
/* Then use TokenBuffer, which is a JsonGenerator:
* (see [JACKSON-175])
*/
TokenBuffer buf = new TokenBuffer(this);
try {
writeValue(buf, fromValue);
// and provide as with a JsonParser for contents as well!
JsonParser jp = buf.asParser();
Object result = readValue(jp, toValueType);
jp.close();
return result;
} catch (IOException e) { // should not occur, no real i/o...
throw new IllegalArgumentException(e.getMessage(), e);