Jordi Niubo
Posts: 0
Joined: Tue Nov 26, 2013 12:08 pm

Save array to local variable and get it in String format. How change to array again?

Hi

I save some items inside one array.
Then, i save as local variable and get it again. Now this is in String format.

I will need to have it in array format again.

I read some functions, like JSON Parser, jQuery.parseJSON, but possible I wrote a wrong code or it's possible I can't use this functions.

Can you tell me if there are any function that make it automaticaly?

Thanks

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Save array to local variable and get it in String format. How change to array again?

Hello! For saving use prelocalStorage.setItem("localVarName", JSON.stringify(varName));/pre for reading prevar varName = JSON.parse( localStorage.getItem("localVarName"));/pre

Jordi Niubo
Posts: 0
Joined: Tue Nov 26, 2013 12:08 pm

Save array to local variable and get it in String format. How change to array again?

ok thanks this work!

Then if I send this to Data Base and get it again will work?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Save array to local variable and get it in String format. How change to array again?

Yes, but there is one thing - while parsing and reading from localStorage you have to check localStorage content. This should help https://getsatisfaction.com/apperyio/...

Return to “Issues”