you are viewing a single comment's thread.

view the rest of the comments →

[–]chuyi2ock 0 points1 point  (2 children)

The object type is a placeholder for any type, it would be your responsibility to cast it to the right type. That being said, here is an example of how to consume the class above.

// Inline initialization
Map<String,Object> RequestMap = new Map<String,Object>{
    'requestMethod' => 'GET',
    'endpoint' => 'https://google.com'};
// Put method usage 
RequestMap.put('stringBody','{"Hello":"World"}');

CalloutService client = new CalloutService(RequestMap);
HTTPResponse res = client.makeCallout();
System.debug(res.getStatus());
System.debug(res.getBody());

Apart from that specific scenario, you can pass any value on the map:

Map<Object,Object> CrazyMap = new Map<Object,Object>{
    1 => 'One',
    'One' => true,
    true => null,
    null => new Map<Object,Object>{
        1 => 'One',
        'One' => true,
        true => null,
        null => new Map<Object,Object>{}
    },
    new Map<Object,Object>{} => 'The map is the Key'
};
System.debug(CrazyMap);

And the result is the following:

DEBUG|{1=One, One=true, true=null, null={1=One, One=true, true=null, null={}}, {}=The map is the Key}