You need to sign in to do that
Don't have an account?

Can anyone please help me with de-serializing, I want to take Json values and map to my fields. I wrote a wrong code but unable to identify my mistake
I think I made mistake in de-serializing & didnot use the map correctly. But not sure how to correct it. Yout help will be really appreciated
@HttpPost
global static void doPost()
{
RestRequest req = RestContext.request;
system.debug('Begin');
RestResponse res = Restcontext.response;
String requestJson = req.requestBody.toString();
map<String, Object> jsonMap = (map<String, Object>) JSON.deserializeUntyped(requestJson);
String Name = String.valueof(jsonMap.get('Name'));
String Gender = String.valueof(jsonMap.get('Gender'));
String Email = String.valueof(jsonMap.get('Email'));
@HttpPost
global static void doPost()
{
RestRequest req = RestContext.request;
system.debug('Begin');
RestResponse res = Restcontext.response;
String requestJson = req.requestBody.toString();
map<String, Object> jsonMap = (map<String, Object>) JSON.deserializeUntyped(requestJson);
String Name = String.valueof(jsonMap.get('Name'));
String Gender = String.valueof(jsonMap.get('Gender'));
String Email = String.valueof(jsonMap.get('Email'));
Please refer the below link for json de-serializing into map
https://developer.salesforce.com/forums/?id=9060G000000IAi7QAG
https://salesforce.stackexchange.com/questions/288695/how-to-convert-json-string-into-map-in-apex
If this helps, Please mark it as best answer.
Thanks!!