{
"name" : "id",
"type" : [ "null", {
"type" : "record",
"name" : "ObjectId",
"namespace" : "org.bson.types",
"fields" : [ {
"name" : "counter",
"type" : {
"type" : "int",
"java-class" : "java.lang.Integer"
}
}, {
"name" : "date",
"type" : [ "null", {
"type" : "long",
"java-class" : "java.util.Date"
} ]
}, {
"name" : "machineIdentifier",
"type" : {
"type" : "int",
"java-class" : "java.lang.Integer"
}
}, {
"name" : "processIdentifier",
"type" : {
"type" : "int",
"java-class" : "java.lang.Short"
}
}, {
"name" : "time",
"type" : {
"type" : "long",
"java-class" : "java.lang.Long"
}
}, {
"name" : "timeSecond",
"type" : {
"type" : "int",
"java-class" : "java.lang.Integer"
}
}, {
"name" : "timestamp",
"type" : {
"type" : "int",
"java-class" : "java.lang.Integer"
}
} ]
} ]
}
{"$oid": <ObjectId bytes as 24-character, big-endian hex
string>}{
"name" : "oid",
"type" : {
"type" : "string"
}
}]
}public class ObjectIdSerializerModifier extends BeanSerializerModifier {
@Override
public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BeanDescription beanDesc, List<BeanPropertyWriter> beanProperties) {
if ( beanDesc.getBeanClass().equals(ObjectId.class) ) {
beanProperties.clear(); // I need to add the 'oid' string element here.
}
return beanProperties;
}
}
com.fasterxml.jackson.databind.exc.InvalidDefinitionException:
"Any" type (usually for `java.lang.Object`) not supported:
`expectAnyFormat` called with type [simple type, class
org.bson.types.ObjectId]
at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)
at com.fasterxml.jackson.dataformat.avro.schema.VisitorFormatWrapperImpl.expectAnyFormat(VisitorFormatWrapperImpl.java:174)
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.acceptJsonFormatVisitor(UnknownSerializer.java:66)
at com.fasterxml.jackson.dataformat.avro.schema.RecordVisitor.schemaFieldForWriter(RecordVisitor.java:178)
at com.fasterxml.jackson.dataformat.avro.schema.RecordVisitor.optionalProperty(RecordVisitor.java:121)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.depositSchemaProperty(BeanPropertyWriter.java:839)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.acceptJsonFormatVisitor(BeanSerializerBase.java:863)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.acceptJsonFormatVisitor(DefaultSerializerProvider.java:566)
at com.fasterxml.jackson.databind.ObjectMapper.acceptJsonFormatVisitor(ObjectMapper.java:4046)
at com.fasterxml.jackson.databind.ObjectMapper.acceptJsonFormatVisitor(ObjectMapper.java:4025)
at com.amitds1997.avroserializer.Main.main(Main.java:55)--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/d9e5d38a-ea0b-472d-99f3-88e0e2280eb9%40googlegroups.com.
'id' : {
'oid' : '24-character-hex-string';
}
To unsubscribe from this group and stop receiving emails from it, send an email to jackso...@googlegroups.com.