Contributions
Re: Which jar files were added to resolve this?
this is my code - my task is to compare two JSON responses and print out their differences If you know another approach, please share Thanks def printJsonObject() { JSONObject parseJsonAct = (JSONObject) new JsonSlurper().parseText(actualResponse); JSONObject parseJsonExp = (JSONObject) new JsonSlurper().parseText(expResponse); for (Object key : json1.keySet()) { //based on you key types String keyStr = (String)key; Object keyvalue = json1.get(keyStr); //Print key and value log.info("key: "+ keyStr + " value: " + keyvalue); //for nested objects iteration if required if (keyvalue instanceof JSONObject) printJsonObject((JSONObject)keyvalue); } } This is the example ofactualResponse - [{"inputs":[{"__typename":"ElementalField"}],"constraint":"FILE-STATUS:REPORT-STATUS:REPORT-STATUS-1='0'","source":{"sourceCodeFiles":[{"fileName":"/usr/src/workspace/PhaseChangeCreditComplex/source/cobol/PCCTRE.cob","sourceLines":[{"nodes":[{"id":"8326"}],"lineNumber":620}]}],"__typename":"Source"},"branchExecuted":false},{"inputs":[{"__typename":"ElementalField"}],"constraint":"FILE-STATUS:TRAND-STATUS:TRAND-STATUS-1='0'","source":{"sourceCodeFiles":[{"fileName":"/usr/src/workspace/PhaseChangeCreditComplex/source/cobol/PCCTRE.cob","sourceLines":[{"nodes":[{"id":"8369"}],"lineNumber":634}]}],"__typename":"Source"},"branchExecuted":false}] Expected response is similar920Views0likes1CommentRe: How to traverse through two JSON responses and get the differences in groovy?
Thanks Comparing 2 maps worked but we can achieve the same with ReadyAPI assertions. My task is to get the differences between the complex json responses. JsonAssert is also mentioned in the article but it supports JUNIT only Any idea how to use this library in ReadyAPI groovy?3 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.1KViews0likes1CommentRe: what is the meaning of '${Request 1#Response}'?
Hi Rao, Yes, I would like to know how to compare JSON responses (actual vs expected) but I was only able to find below (comparing xml documents) https://support.smartbear.com/readyapi/docs/testing/scripts/samples/compare-xml.html Any help on how to compare json responses in a similar manner would appreciate My requirement is not just to print out the actual / expected but to print out their differences in groovy Thanks,3 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.5KViews0likes0CommentsRe: what is the meaning of '${Request 1#Response}'?
Changed response header to accept application/xml in both requests and followed the instructions but this did not work Attaching screenshot of the error and my code sample3 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.5KViews0likes1CommentWhich jar files were added to resolve this?
Hi community, I run into the same error while using Diff class in groovy ReadyAPI version 3.8.0 def actualResponse = testRunner.runTestStepByName("postQueryWithSFGraphIdAndBlankConstraint").getResponse().getContentAsString() def expResponse = context.getTestCase().getPropertyValue("gp") JSONObject parseJsonAct = (JSONObject) new JsonSlurper().parseText(actualResponse); JSONObject parseJsonExp = (JSONObject) new JsonSlurper().parseText(expResponse); // Create an object with differences between documents Diff myDiff = new Diff(parseJsonAct, parseJsonExp) DetailedDiff diff = new DetailedDiff(myDiff) I researched and found this post. Just not able to reply and ask which jar files were missing? https://community.smartbear.com/t5/SoapUI-Open-Source/org-codehaus-groovy-control-MultipleCompilationErrorsException/m-p/132672#M22605 My error attached Ekaterina966Views0likes5CommentsRe: what is the meaning of '${Request 1#Response}'?
Thank you for this input, Rich From the previous answer you provided "The 'Response' bit just means the response of the specified request." 'Response' - is just a string, not a variable holding the response, correct?3 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.2KViews0likes3CommentsRe: How to traverse through two JSON responses and get the differences in groovy?
The expected and actual JSON responses are attached. I removed date and timestamp which appears in the output console after executing log.info () def infoConstActual = context.expand( '${postQueryWithSFGraphIdAndBlankConstraint#Response#$[\'data\'][\'groundProjection\'][\'informationConstraints\']}' ) def infoConstExpected = context.getTestCase().getPropertyValue("gpInfoConstraints")3 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.1KViews0likes3CommentsHow to traverse through two JSON responses and get the differences in groovy?
Hello community, Would anyone know how to traverse through two JSON responses (expected vs actual) and get the differences in groovy? For example - response A is missing 123... and Response B has 456...Solved3 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.1KViews0likes5Comments