Convert JSON String of RESTRequest to Map

apexjsonmap

I'm new to Integration in salesforce.
I'm using RestRequest and getting requestBody something like below:

{"event_source":"","media_source":"restricted"}

I wanted this string to Map but when I use below snippet I'm getting Error as :

**Method does not exist or incorrect signature: void deserializeUntyped(String) from the type String**

String json = '{"event_source":"","media_source":"restricted"}'; 
Map<String, Object> m =   (Map<String, Object>) JSON.deserializeUntyped(json);

Best Answer

Naming your string "json" is shadowing the JSON class, causing you to be unable to use the JSON class in the same scope where this variable is present.

Rename your string variable, or use System.JSON.deserializeUntyped() to get around the shadowing.

Related Topic