fixed serialize to handle mixed types with objectids