Any <-> JSON/XML/YAML can be implemented using compile-time introspection and serialization, see treeform/jsony for example. nimyaml also allows to unmarshall objects to and from. <https://nimyaml.org/serialization.html>
At the same time, solving this problem in general is hardly possible, because each serialization format has its own special quirks and features. For example, how do you map json fields to XML attributes _or_ nested elements? You need to have a schema for this, so you can choose what is an attribute and what is not.