I have Data in MAP<String,sobject> type map and I wants to put it in Map<String,object> type Map. Please help with this casting.
Asked
Active
Viewed 868 times
-1
-
4What have tried? Can you share, with an [edit], what code you currently have even if it doesn't work? – Kris Goncalves Jan 17 '22 at 13:52
1 Answers
2
Sure, you can just write:
Map<String, Object> widerMap = new Map<String, sObject>();
No casting is required to make this work. However, this is due to a bug in the compiler. If you use this technique, be very careful not to try and store an invalid data type in the value, or you'll get a runtime exception.
sfdcfox
- 489,769
- 21
- 458
- 806