| I also think a RichData backend could be difficult for people to adopt especially since you may want this support for both yaml, json, and eyaml. This is why I suggested adding deserialization as an option to existing backends. RichData is really an encoding on top of an existing data format, so this is a natural fit. This could also be done at the lookup_option level similar to how convert_to works. Unfortunately it cannot be done with convert_to since IIRC there is no data type that accepts Pcore as input to its new() and that would return a deserialized value - one could be created though. A general lookup_option feature would be to add a convert_with which has the name of a function as its value. It would be called before a convert_to if both are used. The convert_with would take RichData as an argument and produce Any (although in hiera it would be restricted to returning RichData. Then you can plug in a function like this one: https://github.com/hlindberg/tahu/blob/master/lib/puppet/functions/tahu/convert_from_rich_data.rb to do the deserialization. Or users can do their own simple conversion per key. The same feature could be added as an option to backends. The hiera implementation would then call the given function for every value the backend returns. This way the backend implementations does not have to change. |