I am framing a JSON object in Script tag in HTML screen -
var passingElements = {"options":{"axisY":{"title":"Cups","titleFontSize":15,"labelFontColor":"#000000","labelFontSize":"10"},"axisX":{"labelFontColor":"#000000","labelFontSize":"10","gridColor":"orange"},"toolTip":{"enabled":false}, "data":[{"type":"column","indexLabel":"{x}","indexLabelFontColor":"#000000","dataPoints":[{y: 0.07, label:'3:09 A'},{y: 0.01, label:'1:58 A'},]}]}}
We have saved the JSON object to sessionStorage as sessionStorage.setItem("sessiondata", passingElements);
When we are trying to retrieve the stored data as sessionStorage.getItem("sessiondata"); // Printing as "[object Object]"
Please let me know how can i view the data or use the data which is stored in session storages.
We are working on Titanium Appcelerator tool.
Thanks, Rakesh Kalwa.
Your JSON
var passingElements = {"options":{"axisY":{"title":"Cups","titleFontSize":15,"labelFontColor":"#000000","labelFontSize":"10"},"axisX":{"labelFontColor":"#000000","labelFontSize":"10","gridColor":"orange"},"toolTip":{"enabled":false}, "data":[{"type":"column","indexLabel":"{x}","indexLabelFontColor":"#000000","dataPoints":[{y: 0.07, label:'3:09 A'},{y: 0.01, label:'1:58 A'},]}]}}
To store a JSON object in local storage you will need to convert it into a JSON-formatted string, using the JSON.stringify() function.
sessionStorage.setItem("sessiondata", JSON.stringify(passingElements));
Because the object was previously converted to a JSON-formatted string, you will have to reverse the effects of the stringify function before you can access the data within the object. This is easily done through use of the JSON.parse() function
var obj = sessionStorage.getItem("sessiondata");
obj = jQuery.parseJSON(obj);
console.log(obj)