How to parse response to JSON in gatling

Hi,

I have below response string. How to parse it to JSON so that I can check the value of pcResult using jsonPath(). I don’t want to use regex.

Response String:

{“payload”:"{“pcResult”:“OK”,“pcResultCode”:null,“pcResultDescription”:null,“pcContextString”:{“dsContext”:{“ttContext”:[{“contextName”:“pcSelectedGroups”,“contextValue”:“1”},{“contextName”:“pcStatisticsSeqS”,“contextValue”:“17792”},{“contextName”:“pcTimeStamp”,“contextValue”:“2019-07-10T15:22:32.584”}]}}}",“clientId”:“someClientID”,“cid”:“71”,“eid”:“600”,“event”:“UpdateSelfSchedules”,“batchTotal”:1,“batchOrder”:0}

Can anyone help me, please?

what particular value do you need to check in pcResult? All of it? just a few values?

Hi James,

I need to check the value of pcResult. which is equal to ‘OK’. I want to make sure that value returned for pcResult is OK not ERROR. If I use this .check(jsonPath("$.pcResult").is(“OK”)) This doesn’t work because my response is in string format.
Also, I would like to retrieve the value of pcTimeStamp field.

Response String:

{“payload”:"{“pcResult”:“OK”,“pcResultCode”:null,“pcResultDescription”:null,“pcContextString”:{“dsContext”:{“ttContext”:[{“contextName”:“pcSelectedGroups”,“contextValue”:“1”},{“contextName”:“pcStatisticsSeqS”,“contextValue”:“17792”},{“contextName”:“pcTimeStamp”,“contextValue”:“2019-07-10T15:22:32.584”}]}}}",“clientId”:“someClientID”,“cid”:“71”,“eid”:“600”,“event”:“UpdateSelfSchedules”,“batchTotal”:1,“batchOrder”:0}

Is it possible in Gatling?

Hi, No one is replying, am I asking something wrong?

Hi, your question seems straightforward for a JSONPath expression... Something like jsonPath("$payload.pcResult") doesn't work?

Hi Alan,

No, jsonPath("$payload.pcResult") doesn’t work because of the " added before { bracket. But it’s okay I have used regex like this .check(regex(""".pcResult\":\"OK."""))