Contributions
Re: JsonSlurplerGetting Error while Parsing the Json Response
nmraoThe Json response array is something like below. [ { "AgreementType": "XXXX", "Code": "XXXX", "ShortName": "XXXX", "Name": "XXXX", "Description": "XXXX", "DocumentManagementStoreUrl": null, "IsActive": true, "EffectiveDate": "2013-12-10T00:00:00", "TerminationDate": null, "WasCreatedInError": false, "DataTimeStamp": "2018-05-04T13:34:01Z" }, { "AgreementType": "XXXX", "Code": "XXXX", "ShortName": "XXXX", "Name": "XXXX", "Description": "XXXX", "DocumentManagementStoreUrl": null, "IsActive": true, "EffectiveDate": "2013-12-10T00:00:00", "TerminationDate": null, "WasCreatedInError": false, "DataTimeStamp": "2018-05-04T13:34:01Z" }, { "AgreementType": "XXXX", "Code": "XXXX", "ShortName": "XXXX", "Name": "XXXX", "Description": "XXXX", "DocumentManagementStoreUrl": null, "IsActive": true, "EffectiveDate": "2013-12-10T00:00:00", "TerminationDate": null, "WasCreatedInError": false, "DataTimeStamp": "2018-05-04T13:34:01Z" }, { "AgreementType": "XXXX", "Code": "XXXX", "ShortName": "XXXX", "Name": "XXXX", "Description": "XXXX", "DocumentManagementStoreUrl": null, "IsActive": true, "EffectiveDate": "2013-12-10T00:00:00", "TerminationDate": null, "WasCreatedInError": false, "DataTimeStamp": "2018-05-04T13:34:01Z" }3KViews0likes1CommentRe: JsonSlurplerGetting Error while Parsing the Json Response
nmraoJHuntThanks for the update.I am now able to get the response json in UTF-8 format. Nowthe Json array count is showing 0 eventhough I have many array elements. Please see below the output. Please could you get a fix for this issue as well.3KViews0likes1CommentRe: JsonSlurplerGetting Error while Parsing the Json Response
JHuntThanks for your update. Could you please tell me how toadd or amend the 'Accept/Encoding header' on therequest as I am not an expert in this. Also when I checked the Raw format of the file I could see some special character in the response which is not present in the JSON format response Please note I am alwaysselecting theencoding as 'UTF-8' in the properties. Please see below. This is the encoding type I have selected.3KViews0likes0CommentsRe: JsonSlurplerGetting Error while Parsing the Json Response
Hi All, Finally, I found a workaround for this issue. I passed the Json response to "def json = JsonOutput.toJson(response)" based on thisstackoverflow question. Now the response is successfully parsed evenif the special characters are present The Groovy code will be something like this. import groovy.json.* def responseContent = testRunner.testCase.getTestStepByName("Name of the Test Step").getPropertyValue("response") def json = JsonOutput.toJson(responseContent) def result = new JsonSlurper().parseText(json) log.info result Lets see how it goes and I will update you.3KViews0likes0CommentsRe: JsonSlurplerGetting Error while Parsing the Json Response
avidCoderThanks 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 dataon 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.3.6KViews0likes3CommentsRe: JsonSlurplerGetting Error while Parsing the Json Response
Apologies for not adding the JSON Response. Please see below the JSON Response array I am receiving for the service [ { "Type": "XXXX", "Code": "XXXXX", "ShortName": "ShortName", "Name": "Long Name (Including Special Characters like ',-,\," etc)", "Description": "Description of the Service Agreement (Including Special Characters like ',-,\," etc)"", "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": "Long Name (Including Special Characters like ',-,\," etc)", "Description": "Description of the Service Agreement (Including Special Characters like ',-,\," etc)"", "DocumentManagementStoreUrl": null, "IsActive": true, "EffectiveDate": "2013-12-10T00:00:00", "TerminationDate": null, "WasCreatedInError": false, "DataTimeStamp": "2018-04-30T08:42:45Z" }, { ..... }, { ..... }, ]3.6KViews0likes7CommentsJsonSlurplerGetting Error while Parsing the Json Response
I tried tocreate a groovy script to parse the JSON response to a variable using JsonSlurper. Though the response Json is in valid format, i am getting an error def responseContent = testRunner.testCase.testSteps["Neme fof the test step"].testRequest.response.contentAsString def Response = new JsonSlurper().parseText(responseContent) log.info Code Could some one please look into this issue provide me a workaround for this. Thanks in advance4.9KViews0likes20Comments