kgiszczak / shale

Shale is a Ruby object mapper and serializer for JSON, YAML, TOML, CSV and XML. It allows you to parse JSON, YAML, TOML, CSV and XML data and convert it into Ruby data structures, as well as serialize data structures into JSON, YAML, TOML, CSV or XML.
https://shalerb.org/
MIT License
618 stars 19 forks source link

Allow to render empty nodes in xml if value is nil #4

Closed Tab10id closed 1 year ago

Tab10id commented 1 year ago

For some reasons we need to render empty xml nodes even if actual value absence. For now the only available solution to add || '' for every attributes in decorator. Similar feature we have in representable: https://trailblazer.to/2.1/docs/representable.html#representable-function-api-render-nil Do you have plans to implement such feature? I understand that it can make deserialization process more complicated.

kgiszczak commented 1 year ago

Hey, I just released a new version that solves this. You can use render_nil: true to control rendering. Release notes are here: https://www.shalerb.org/releases.html#v070

I'll close the issue, if you need anything create a new one, thanks.