Adds function for proper object to JSON serialization