Brani
July 10, 2019, 11:24pm
1
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}
Brani
July 13, 2019, 2:15am
2
Can anyone help me, please?
what particular value do you need to check in pcResult? All of it? just a few values?
Brani
July 15, 2019, 9:08pm
4
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}
Brani
July 19, 2019, 6:56pm
5
Is it possible in Gatling?
Brani
July 25, 2019, 4:12pm
6
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?
Brani
July 31, 2019, 6:52pm
8
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. """))