-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Closed
Description
I've written a small Serializer for MongoDB's ObjectId:
public class ObjectIdSerializer extends StdSerializer<ObjectId> {
public static final ObjectIdSerializer INSTANCE = new ObjectIdSerializer();
private ObjectIdSerializer() { super(ObjectId.class); }
@Override public void serialize(ObjectId value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
jgen.writeString(value.toHexString());
}
}
And a SimpleModule:
@Component
public class CommonJacksonModule extends SimpleModule {
public CommonJacksonModule() {
super(new Version(1, 0, 0, null, null, null));
addSerializer(ObjectId.class, ObjectIdSerializer.INSTANCE);
}
}
When using Accept=application/json it works as expected and I get something like "5498374f44ae6f110dd0abcd". But using Accept=application/xml I get something like:
<new>false</new>
<timeSecond>1419261775</timeSecond>
<inc>231792298</inc>
<machine>1152282385</machine>
<time>1419261775000</time>
<date>2014-12-22T15:22:55.000+0000</date>
<timestamp>1419261775</timestamp>
What's the problem here?
elcodedocle
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug