Forum Discussion
nmrao
Champion Level 3
Well, it would help if you can provide source and target data (need not be exact), at least resembling your data structure.
InekeBauw
7 years agoOccasional Contributor
For example this is an response payload of a PUT.
So if there is an extra element then these two, test should fail.
{
"ExternalReference": "Testing6",
"ErrorLog": []
}
- nmrao7 years agoChampion Level 3Is the provided response structure is same as your original response? does it have any recursive? Because, solution would be completely relate to data. If data differs, solution would differ.
- TNeuschwanger7 years agoChampion Level 2
sample groovy test step code that should meet you need...
def someJSON = '''
{
"ExternalReference": "Testing6",
"OtherStuff": "Goop6",
"ErrorLog": []
}
''';
def jsonContent = new groovy.json.JsonSlurper().parseText(someJSON);
log.info 'jsonContent=' + jsonContent;
log.info 'jsonContent=' + jsonContent.size();
assert jsonContent.size() <= 2, "we expected at least 2 elements but got " + jsonContent.size();
Related Content
- 6 years agoucuber