fixed error in serialize()

This one was preventing objects to serialize to strings and crashing the app when it tried to.