invalid json response

Hi Stephane,

I need to transform response body before extracting jsonpath, as response body is having some special characters.
here is the response :

{“controllerData”:{“MashupRefs”:{“MashupRef”:[{“mashupId”:“isf.shipment-pick.getShipmentDetails”,“Output”:{“Shipment”:{“Status”:{“Status”:“1100.70.06.10”,“Description”:“Ready For Backroom Pick”},“IsOverdue”:“true”,“DeliveryMethod”:“PICK”,“DocumentType”:“0001”,“ImageUrl”:“isf\x2Fresources\x2Fcss\x2Ficons\x2Fimages\x2FtimeOverdue.png”,“OrderNo”:“3100000240”,“Status_scattr”:“1100.70.06.10”,“DisplayOrderNo”:“3100000240”,“ShipmentNo”:“100000140”,“ShipmentKey”:“202108102030071344685”,“SLACssClass”:“time_overdue”,“ExpectedShipmentDate”:“2021-08-10T22\x3A30\x3A08\x2B00\x3A00”,“TimeRemaining”:“Delayed by 3 d”,“SellerOrganizationCode”:“BAY”,“ShipNode”:“1101”,“OrderHeaderKey”:“202108102029241344371”,“EnterpriseCode”:“BAY”,“ImageAltText”:“Overdue”}},“mashupRefId”:""},{“mashupId”:“isf.shipment-pick.getAllPickableShipmentLineList”,“Output”:{“ShipmentLines”:{“TotalQuantity”:“1”,“ShipmentLine”:[{“OriginalQuantity”:“1”,“UnitOfMeasure”:“EACH”,“Shipment”:[{“Currency”:“CAD”,“EnterpriseCode”:“BAY”}],“DocumentType”:“0001”,“ImageURL”:“https\x3A\x2F\x2Fs7d9.scene7.com\x2Fis\x2Fimage\x2FTheBay\x2F\x2F0703113596452_main”,“Quantity”:“1”,“OrderNo”:“3100000240”,“Extn”:{“ExtnIsInternational”:“N”},“ItemID”:“90407099”,“ShipmentKey”:“202108102030071344685”,“ShipmentTagSerials”:{},“ShipmentLineKey”:“202108102030071344684”,“ShortageQty”:“0”,“ShipmentSubLineNo”:“0”,“OrderLine”:{“ItemDetails”:{“DisplayUnitOfMeasure”:“Each”,“UnitOfMeasure”:“EACH”,“AttributeList”:{“Attribute”:[{“Value”:“BLACK”,“Name”:“Color”},{“Value”:“One Size”,“Name”:“Size”}]},“Extn”:{“ExtnDivision”:“KITCHEN”,“ExtnVendorStyle”:“059645”,“ExtnClass”:“010”,“ExtnJewelryFlag”:“N”,“ExtnDepartment”:“636”,“ExtnDepartmentName”:“HOME”},“UOMDisplayFormat”:“formattedQty”,“ItemID”:“90407099”,“ClassificationCodes”:{“Model”:“0600090407099”},“InventoryParameters”:{“IsSerialTracked”:“N”},“AdditionalAttributeList”:{“AdditionalAttribute”:[{“Value”:“BLACK”,“Name”:“Color”},{“Value”:“One Size”,“Name”:“Size”}]},“ItemGroupCode”:“PROD”,“ItemAliasList”:{“ItemAlias”:[{“AliasValue”:“703113596452”,“AliasName”:“ACTIVE_UPC”}]},“Variation”:“BLACK \x7C One Size”,“PrimaryInformation”:{“Description”:“Dept NameHOME Class desc COUNTERTOP BLENDERS Brand Vitamix VITA-MIX,CORP. 059645 VITAMIX 6500 - BLACK”,“ManufacturerName”:“Vitamix”,“ImageID”:“0703113596452_main”,“ExtendedDisplayDescription”:“6500 Blender \x2890407099\x29”,“ImageLocation”:“https\x3A\x2F\x2Fs7d9.scene7.com\x2Fis\x2Fimage\x2FTheBay\x2F”}},“CarrierServiceCode”:"",“ItemGroupCode”:“PROD”,“IsBundleParent”:“N”},“OrderHeaderKey”:“202108102029241344371”,“ProductClass”:"",“Variation”:“BLACK \x7C One Size”,“ShipmentLineNo”:“1”,“BackroomPickedQuantity”:"",“OrderLineKey”:“202108102029241344372”}],“TotalNumberOfRecords”:“1”}},“mashupRefId”:""}]}}}

Request :

.exec(http(“request_24”)
.post("/isf/store/mashupController.do")
.headers(headers_24)
.formParam(“scControllerData”, “”"{“MashupRefs”:{“MashupRef”:[{“mashupId”:“extn.isf.shipment-pick.pick-order-list.getSFSPickOrderList”,“Input”:{“Shipment”:{“ComplexQuery”:{“And”:{“Or”:[{“Exp”:[{“Name”:“Status”,“QryType”:“EQ”,“Value”:“1100.70.06.10”}]},{“Exp”:[{“Name”:“DocumentType”,“QryType”:“FLIKE”,“Value”:“0001”},{“Name”:“DocumentType”,“QryType”:“FLIKE”,“Value”:“0006”}]}]}},“DeliveryMethod”:“PICK”,“OrderBy”:{“Attribute”:{“Desc”:“N”}}}},“isPaginated”:“true”,“scPageSize”:“10”,“scPageNumber”:“1”,“scPaginationStrategy”:“NEXTPAGE”}],“isMultiAPICall”:false}}""")
.formParam(“scCSRFToken”, “${scCSRFToken}”)
.formParam(“scFlag”, “Y”)

.check(jsonPath("$.controllerData.MashupRefs.MashupRef[0].Output.Page.Output.Shipments.Shipment[0].ShipmentKey").find.saveAs(“ShipmentKey”)))
// .check(jsonPath("$").saveAs(“req11”)))

Thanks
Trisha

Are you using the latest 3.6.1 Gatling version?

Hi Stephane,

I am using 3.5.1 version

Your response JSON payload is clearly malformed.

Strings such as isf\x2Fresources\x2Fcss\x2Ficons\x2Fimages\x2FtimeOverdue.png are obviously encoded in hex format but \ is the JSON escape character, so it should be escaped for JSON => isf\x2Fresources\x2Fcss\x2Ficons\x2Fimages\x2FtimeOverdue.png

Then, the correct way would be to NOT encode into hex and only use the correct JSON escaping so you would simply write isf/resources/css/icons/images/timeOverdue.png.

Instead of trying to work around this application issue downstream, why not report it to the application developers so that they actually fix it on their side?

Hi Stephane,

Is there any workaround for now ? because we are very near to the delivery date.

PLease provide solution, i am really having a hard time with this

https://gatling.io/docs/gatling/reference/current/http/request/#response-transformers

Thanks Stephane,

But it is still not working for me, please can you point what mistake i am doing. Here is the code