function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sujit Das@AccentureSujit Das@Accenture 

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

Hi,

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.

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

Controller:
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"},[],[]]
NarutoNaruto
Did you got the answer, if 'yes' could you post it.
Dinesh_Kumar_NagarathinamDinesh_Kumar_Nagarathinam
Can you show the format of taskList? Do console.log(taskList) and post the result here.so that we can analyze it.