Enable toJSON function to return simple types