2

I have map value like

 mapModelLabel >>>>>{GM2 E3A MC M=GM2 E3A MC M, GM2 E3A MS M=GM2 E3A MS M}

code

strJSON= res.getBody();
    system.debug('strJson>>>>>'+strJSON);

Map<String,Object> mapJSON = (Map<String,Object>) JSON.deserializeUntyped(strJSON);
Map<String,Object> mapLocalSemi = (Map<String,Object>)mapJSON.get('localSemiClair');
Map<String,Object> mapMapRep = (Map<String,Object>)mapLocalSemi .get('mapRepresentation'); 
Map<String,Object> mapValues = (Map<String,Object>)mapMapRep.get('map');

I want to convert into map

how can i achieve this ?

2

So you can try like this

map<string,string> newMap= new Map<string,string>();
for(String strKey: mapValues.keyset())
{
    newMap.put(strKey, String.valueof(mapValues.get(strKey)));
}
0

I have tried this worked for me:

enter code here

map<string,object> mspstrToObj = new Map<string,object>();
mspstrToObj.put('key1', 'obj1');

map<string,string> mspstrTostr = new Map<string,string>();

mspstrTostr.put('strKey1',string.valueof(mspstrToObj.get('key1')));

system.debug('=======mspstrTostr====='+mspstrTostr);

You need to create new Map and put the values as per above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.