I've made do with .to_xml, use xlst on results, then .to_json. It definably works (with some caveats) but would love to cut out the middleman. I believe xlst 3.0 added explicit json support but I've yet to give it a try:
https://www.saxonica.com/papers/xmlprague-2016mhk.pdf