I have a list like [gender, axonVoucherCode]
Also I have a Json Array [[gender:Gender?], [concussionHistory:History of previous concussion?], [previousConcussion:Number of previous concussions?], [historyMigraineChronic:History of migraine or chronic headaches?], [edTreatment:ED treatment ?], [axonVoucherCode:Axon Voucher Code ?]]
I want to make a list with corresponding value of 1st list like [Gender?,Axon Voucher Code ?] .I use JsonSlurper for parsing Json .
def fetchQuestion(def list){
def webRootDir = SCH.servletContext.getRealPath("/")
def f = new File(webRootDir + "/jsons/" + "QuestionPart1")
def questionList = new JsonSlurper().parseText(f.text)
def newlists=[]
println questionList.QuestionPart1
questionList.QuestionPart1.each{
println(it)
}
println(newlists);
return newlists
}
//I want to put matching value to newlists
Here is my JSON file format .
{"QuestionPart1":[
{"gender":"Gender?"},
{"concussionHistory":"History of previous concussion?"},
{"previousConcussion":"Number of previous concussions?"},
{"historyMigraineChronic":"History of migraine or chronic headaches?"},
{"edvisitTime":"Date and time of ED visit?"},
{"injuryTime":"Date and time of Injury?"},
{"mechanismInjury":"Mechanism of Injury?"},
{"sportsType":"Choose Sport?"},
{"signAndSymptom":"Select the signs and symptoms the subject experienced following injury?"},
{"durationLossConsciousness":"Duration of loss of Conciousness ? "},
{"durationBeforeAmnesia":"Duration of Amnesia for events BEFORE injury ?"},
{"durationAfterAmnesia":"Duration of Amnesia for events AFTER injury ?"},
{"ctObtainedED":"Head CT obtained in ED ?"},
{"edTreatment":"ED treatment ?"},
{"axonVoucherCode":"Axon Voucher Code ?"}
]}
Please help me to solve this problem .Thanks