Forum Discussion
nmrao
9 years agoCommunity Hero
Well, it would help if you can provide source and target data (need not be exact), at least resembling your data structure.
- InekeBauw9 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": []
}- nmrao9 years agoCommunity HeroIs 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.
- TNeuschwanger9 years ago
Champion Level 3
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();