+ Start a Discussion
Rahul AlladaRahul Allada 

error: Illegal assignment from Object to Map<String,String>

String input = '{"orgId":{"isRequired":"true", "valiateDataType": "Id"},"numOfVehicles":{"isRequired": "true"}}';
Map<String,object> o = (Map<String,object>) JSON.deserializeUntyped(input);
map<string,Id> mapsOfIds = new map<string,Id>();
for(string key : mapOfIds.keyset()){
    map<string,string> mapIter = o.get(key);

I have a code as above and i am getting the error Illegal assignment from Object to Map<String,String>  at last line where i am assigning mapIter.

Surya GSurya G
Hi Rahul,

In the last line 'o.get(key)' returns an object. it cannot be assigned to map.

You can change the code to following\
for(string key : mapOfIds.keyset()){
    Object obj = o.get(key);
Surya G