+ Start a Discussion
Sujit Das@AccentureSujit Das@Accenture 

JSON.stringify: Converting Task[] into JSON string returns only 1st row value


When I am trying to convert a array of task into JSON string in my lightning controller, only the 1st element is returned always even though the array has more values. Here is the code. Has anyone faced the same issue.

<aura:attribute type="Task[]" name="listTask" />

var taskList = component.get("v.listTask"); //tried var taskList = component.get("v.listTask").slice(); as well
console.log(taskList.length); //Length is returned correctly e.g. 3

//converting the array into JSON string
var JSONStr = JSON.stringify(taskList); 
console.log(JSONStr); // [{"sobjectType":"Task","ActivityDate":"2016-3-3","Status":"In Progress","Subject":"task1"},[],[]]
Did you got the answer, if 'yes' could you post it.
Can you show the format of taskList? Do console.log(taskList) and post the result here.so that we can analyze it.