I'm getting error in the following apex method: System.TypeException: Invalid conversion from runtime type List to Map<String,ANY>
Please find the apex method:
@AuraEnabled(cacheable=true)
public static void updateQuantity(String recordId, Object quantity){
System.debug('recordId--------->' + recordId + 'quantity------->' + quantity);
Map<String, Object> quantityWrapper = (Map<String, Object>)JSON.deserializeUntyped(JSON.serialize(quantity));
List<Map<String, Object>> quantityJSON = new List<Map<String, Object>>();
for (Object instance : (List<Object>)quantityWrapper.get('quantityJSON'))
quantityJSON.add((Map<String, Object>)instance);
system.debug('quantity:'+quantityJSON);
}
JSON: Following are the draftValues from LWC Component.
[
{
"splitQuantityValue": "30",
"Id": "row-0"
},
{
"splitQuantityValue": "30",
"Id": "row-1"
},
{
"splitQuantityValue": "30",
"Id": "row-2"
}
]
Any kind of help is appreciated.