[SalesForce] How to convert a JSON requestBody of the RestRequest to a Map of Strings

A type of the body is JSON Blob in a form of:

{"key1":"val1";"key2":"val2"}

I wanted to convert it into a Map<String, String>. Do I have to manually deserialize it or there's a class which can handle that?

Best Answer

Let me google that for you...

https://www.google.co.uk/search?q=salesforce+json+deserialize

The class is called JSON, and the method is:

public static Object deserializeUntyped(String jsonString)

So you use it as:

Map<String, Object> myMap = (Map<String, object>)JSON.deserializeUntyped(jsonString);
Related Topic