Forum Discussion

tomaszarmata's avatar
tomaszarmata
Contributor
10 years ago

Bulding json from xml

Hello,   I have tried to build json body from xml. Take file, parse it, make groovy object, then json.   I build groovyObject first becouse I need in next steps to set up values for method, path ...
  • tomaszarmata's avatar
    10 years ago

    After some discusion i try do it that way.

     

    def rootName = null
    def root = [:]
    def connector = []
    def map = [:]
    
    rootName = parsedXml.resource.name.text()
    parsedXml.resource.parameters.parameter.each{
    	map.put( it.text(), null )
    }
    
    connector.add(map)
    root.put (rootName,connector)