chathurad
8 years agoContributor
Cant write json output to a XML file
Below is my code to specifically get values at
result._source.city
node.
import net.sf.*;
import net.sf.json.*;
import net.sf.json.groovy.*;
import net.sf.json.groovy.JsonSlurper;
def ResFile ="C:/driver/Response1.xml"
def Res = context.expand( '${GetAllSchoolsForNZ#Response}' )
def slurper = new JsonSlurper()
def json = slurper.parseText Res
def countryList = json.result._source.city
log.info countryList
def j = new File(ResFile)
j.write(countryList, "UTF-8",true)
But when i execute it im gettint an error like this.
Spoiler
No signature of method: java.io.File.write() is applicable for argument types: (java.util.ArrayList, java.lang.String, java.lang.Boolean) values: [[Rotorua, Christchurch, Auckland, Auckland, ...], ...] Possible solutions: write(java.lang.String, java.lang.String), write(java.lang.String), wait(), size(), canWrite(), delete()
So how am i going to write my data in to a xml file? or any other file?