Forum Discussion
nmrao
Champion Level 3
//Assign your json to below variable and uncomment
//def jsonString = ''' your string goes here '''
def parsedJson = new groovy.json.JsonSlurper().parseText(jsonString)
def items = parsedJson.getResubmittedReturnsResult.getResubmittedReturnsIdentificationOut
def meids = items.meid
def submitCounts = items.submitCount
log.info meids
log.info submitCounts
Can you please check the above?
CByler
9 years agoContributor
I'm sorry Rao,
I don't quite understand what you mean by
Assign your json to below variable
What string do I place there? And how to I dictate that I only get 2's and 3's? I'm not very literate in groovy scripting. I see that you have two comments regarding meids:
def meids = items.meid
def submitCounts = items.submitCount
log.info meids
Just trying to understand why the meids would be relevant for what I'm trying to accomplish. Can the sample I attached, where I modified your prior script, not be fixed to work in this case? I wanted to get comfortable with modifying that if possible so I can reuse it for different response parameters in other web service calls :)
- nmrao9 years agoChampion Level 3
def jsonString = '''{
"getResubmittedReturnsResult":{
"getResubmittedReturnsIdentificationOut":[
{
"meid":671,
"transID":92556,
"status":"Resubmitted",
"submitCount":"2",
"addedTime":"09/23/2016 14:28:49"
},
{
"meid":671,
"transID":92558,
"status":"Resubmitted",
"submitCount":"3",
"addedTime":"09/23/2016 14:28:52"
}
]
}
}'''
def parsedJson = new groovy.json.JsonSlurper().parseText(jsonString)
def items = parsedJson.getResubmittedReturnsResult.getResubmittedReturnsIdentificationOut
def shouldNotBePresent = [1, 4]
//Currently the value received in submitCount is String type, so coverting to Integer
def submitCounts = items.submitCount.collect { it as Integer}
log.info submitCounts
assert [] == shouldNotBePresent.intersect(submitCounts), "There are unwanted submitCount value present in the response"sorry for multiple cycles. Hope this helps.
Related Content
- 9 years ago
- 6 years ago
- 6 years ago
- 2 years ago
Recent Discussions
- 18 days ago