Forum Discussion
Hey, Would you please try below code:-
import groovy.json.JsonSlurper def json = '''[ { "Type": "XXXX", "Code": "XXXXX", "ShortName": "ShortName", "Name": "", "Description": "", "DocumentManagementStoreUrl": null, "IsActive": true, "EffectiveDate": "2013-12-10T00:00:00", "TerminationDate": null, "WasCreatedInError": false, "DataTimeStamp": "2018-04-30T08:42:45Z" }, { "Type": "XXXX", "Code": "XXXXX", "ShortName": "ShortName", "Name": "", "Description": "", "DocumentManagementStoreUrl": null, "IsActive": true, "EffectiveDate": "2013-12-10T00:00:00", "TerminationDate": null, "WasCreatedInError": false, "DataTimeStamp": "2018-04-30T08:42:45Z" } ]''' def code = new JsonSlurper().parseText(json) log.info code
you have used some unexpected character "/" because of which you might be getting errors. I have removed these characters from "Name" and "Description" key.
Here is how you will get the output of the above code:-
Mon Apr 30 18:35:23 IST 2018:INFO:[{Code=XXXXX, DataTimeStamp=2018-04-30T08:42:45Z, Description=, DocumentManagementStoreUrl=null, EffectiveDate=2013-12-10T00:00:00, IsActive=true, Name=, ShortName=ShortName, TerminationDate=null, Type=XXXX, WasCreatedInError=false}, {Code=XXXXX, DataTimeStamp=2018-04-30T08:42:45Z, Description=, DocumentManagementStoreUrl=null, EffectiveDate=2013-12-10T00:00:00, IsActive=true, Name=, ShortName=ShortName, TerminationDate=null, Type=XXXX, WasCreatedInError=false}]
avidCoder Thanks for your update. Its working fine when I removed the Name and Description fields.
However, for the testing purpose, this is not a feasible solution. I'm receiving this data via an API, I don't have the means to force any form of changing the data on the server side, this data is provided to me as-is.
Could you suggest me a workaround for fixing this issue as I wont be able to manually copy the response and clear the fields each time when I want to run a test.
- avidCoder7 years agoSuper Contributor
Hi Rakesh,
Whatever Json you have mentioned above is not correct. There is some problem with the special characters being used there.
Attached is the screenshot for the reference. Please fix the Json problem first. Ultimately, that issue will be resolved.
Thanks.
avidcoder
- rakesh1337 years agoOccasional Contributor
avidCoder I think this is certainly a limitation with the JsonSlurper Parser to handle the json responses with special characters.
Is there any other Parser available in Soap UI
- nmrao7 years agoChampion Level 3rakesh133, the is invalid, the special characters needs to be escaped.
Please check here:
http://jsonviewer.stack.hu/
Related Content
- 4 years ago
- 9 years ago
Recent Discussions
- 16 hours ago