public Object toObject(DataInputStream input) throws IOException {
   Integer version = 0;
   if (hasVersion) version = Integer.valueOf(input.readByte());
   JsonTypeDefinition typeDef = typeDefVersions.get(version);
   if (typeDef == null)
     throw new SerializationException("No schema found for schema version " + version + ".");
   return read(input, typeDef.getType());
 }
 public void toBytes(Object object, DataOutputStream output) throws IOException {
   Integer newestVersion = typeDefVersions.lastKey();
   JsonTypeDefinition typeDef = typeDefVersions.get(newestVersion);
   if (hasVersion) output.writeByte(newestVersion.byteValue());
   write(output, object, typeDef.getType());
 }
 public JsonTypeSerializer(String typeDef) {
   this(JsonTypeDefinition.fromJson(typeDef));
 }