function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Girish Reddy 52Girish Reddy 52 

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'));        
AnkaiahAnkaiah (Salesforce Developers) 
Hi Girish,

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!!