I need to pass List<WrapperClass>
from lightning helper to apex class. Passing the list directly gave me the following error while iterating the list in apex.
Error message: An internal server error has occurred Error ID: 1137130244-1625 (119852647)
So I tried to stringify the list in helper and passed it as a string .This time I am getting the below error in apex.
QueryResult must start with '{'
Please find my code.
public class WrapperClass{
@auraEnabled
public Custom1__c custom1{get;set;}
@auraenabled
public Custom2__c custom2{get;set;}
@auraenabled
public List<Custom3__c> custom3List{get;set;}
@auraenabled
public List<String> currentList{get;set;}
}
Lightning helper:
var action1 = component.get("c.saveCustomVolumes");
{
var customs = component.get("v.customIds");
var tvList = component.get("v.wrapperList");
var tvString = JSON.stringify(tvList);
var baseYear = component.get("v.selectedYear");
action1.setParams({
"customList":customs,
"tvString":tvString, // passing wrapper class as a String
"baseYear":baseYear
});
action1.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
}
Apex class:
@auraenabled
public static saveCustomVolumes(List<String> customList,String tvString, String baseYear){
List<WrapperClass> wrapList =
(List<WrapperClass>)JSON.deserialize(tvString,List<WrapperClass>.class); //This line gives the error QueryResult must start with '{'
}
Could anyone please help me with the issue.