I have this code:
var string = '{"items":[{"Desc":"Item1"},{"Desc":"Item2"}]}'; localStorage.setItem('added-items', JSON.stringify(string));
This code will use localStorage.
Here is the code for retrieving the saved data:
var retrievedObject = localStorage.getItem('added-items');
My problem now is how can I get the size of the data items? the answer should be 2.
How can I get "Item1" and "Item2"?
I tried retrievedObject[0][0] but it does not work.
And how to add data to it? therefore he will
{"items":[{"Desc":"Item1"},{"Desc":"Item2"},{"Desc":"Item3"}]}
Can I use JSON.stringify ?
json javascript local-storage
Jma
source share