ccocchi / rabl-rails

Rails 4.2+ templating system with JSON, XML and Plist support.
MIT License
209 stars 51 forks source link

Add replace_nil_values_with_empty_strings option #38

Closed danielevans closed 10 years ago

ccocchi commented 11 years ago

I'm not sure to understand why a client would prefer to receive empty string than null. Moreover, here you're only replacing nil values for attributes. What should happen if the result from a node or a merge includes nil values? Or if a child is nil, it seems wrong to send an empty string.

@danielevans If you have exemple of clients only accepting empty strings I can try to include this option, but for now I prefer to let null in response.

danielevans commented 11 years ago

@ccocchi I implemented because it is an option that exists and we are currently using with stock rabl. I have an iOS client implemented to accept empty strings differently than null values.

I'll happily go back and re-address node and merge includes and see how rabl handles them, they were an oversight by me.

Thanks!