The previous Question is linked here: Apex Class Error Message: System.JSONException: No content to map to Object due to end of input
I have updated the code If I use the below code where String is Dynamic, I am getting the above error but when I hard code the values, I get the response
In debug Logs the value of selrec is : [{"recId":"abc"},{"recId":"def"}] Code Generating the error:
public with sharing class getmypicklistvalues{
@AuraEnabled(cacheable=true)
public static List<String> fetchPickListValue(String searchKey , String selrec){
system.debug('The value is selected'+selrec);
List<String> pickListValuesList= new List<String>();
If(selrec != NULL || String.isNotBlank(selRec)){
List<Object> selectedvalues = (List<Object>)JSON.deserializeUntyped(selrec);
for(Object slval: selectedvalues){
Map<String,Object> data = (Map<String,Object>)slval;
system.debug('The value of Object is'+data.get('recId'));
}
}
}
}
But when I hardcode the values to Deserialize the JSON response, I am getting the desired result.
public with sharing class getmypicklistvalues{
@AuraEnabled(cacheable=true)
public static List<String> fetchPickListValue(String searchKey , String selrec){
system.debug('The value is selected'+selrec);
List<String> pickListValuesList= new List<String>();
If(selrec != NULL || String.isNotBlank(selRec)){
List<Object> selectedvalues = (List<Object>)JSON.deserializeUntyped('[{"recId":"Angio Detect"},{"recId":"Animana Data Conversion"}]');
for(Object slval: selectedvalues){
Map<String,Object> data = (Map<String,Object>)slval;
system.debug('The value of Object is'+data.get('recId'));
}
}
}
}
I am not sure what I am missing here. FYI selrec will be NULL initially and the values will be loaded once users makes a selection.