Q:

convert a node object to a JSON object in groovy

With this code, it returns a node object of a xml document
def rootNode = new XmlParser().parseText(text)

How can you parse this object into a JSON object (perhaps using JsonBuilder) ?
I did try to pass by a String object (XmlUtil.serialize(rootNode)) but it didn't work out.
Is there anything that I could use or do I need to create something of my own ?
Thanks in advance

A:

You have to roll your own solution. 
Json has no concept of attributes, and you will need to decide what to do with sibling tags of the same name.
There's no immediate obvious way to map from xml to Json

