Page 1 of 1

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

Posted: Mon Jan 13, 2014 10:56 am
by Jordi Niubo

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


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

Posted: Mon Jan 13, 2014 11:24 am
by Maryna Brodina

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


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

Posted: Mon Jan 13, 2014 11:56 am
by Jordi Niubo

ok thanks this work!

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


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

Posted: Mon Jan 13, 2014 3:02 pm
by Maryna Brodina

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/...


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

Posted: Fri Jan 17, 2014 8:34 am
by Jordi Niubo

ok thanks Maryna i will try :)