-1

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.

1
  • 4
    What have tried? Can you share, with an edit, what code you currently have even if it doesn't work? Commented Jan 17, 2022 at 13:52

1 Answer 1

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.

Not the answer you're looking for? Browse other questions tagged .