I have a platform event trigger that takes in a json string which contains an array of objects. My postman test call looks like this:
"testCodeList__c":"[{\"testCode\":\"000000\",\"testName\":\"AAA\",\"procedureClass\":\"XX\"},{\"testCode\":\"111111\",\"testName\":\"BBB\",\"procedureClass\":\"YY\"},{\"testCode\":\"222222\",\"testName\":\"CCC",\"procedureClass\":\"ZZ\"}]"
(note that the quotes are each escaped with backslashes but when I submit this Stack Exchange post, it removes them)
My trigger uses json.deserializeUntyped like this:
List<Object> lstTestCodes = (List<Object>) JSON.deserializeUntyped(evt.testCodeList__c);
This trigger code works just fine, however I cannot get my test class to work. Inside the test class I am setting up a platform event with this parameter:
testOrder.testCodeList__c = '[{"testCode":"000000","testName":"AAA","procedureClass":"XX"},{"testCode":"111111","testName":"BBB","procedureClass":"YY"},{"testCode":"222222","testName":"CCC","procedureClass":"ZZ"}]';
And when I run the test class, I get 'null input to JSON parser'. I have tried both escaping the quotes with backslash, and not escaping them, but I get the same problem. I have done a ton of Googling. Can anyone show me how I can set up my variable in my Apex test class? thanks!
JSON.deserializeUntyped
the value is gettingnull