Array of JSON objects are stored in HTML5 localStorage
.
For now delimiter is ;
For accessing and modifying array of objects from localStorage
, split(';')
and join(';')
operations used.
However ,delimiter approach looks unstable.
For instance ;
could be met inside objects attribute and split(';')
operation will be uncorrect.
It could be used ;;
for delimiter,but i'm not certain it will be stable also.
Is there any robust way to handle localStorage
presented as array of objects,as far localStorage
saved as String
?
EDIT
one of stoppers is that array of object couldn't be saved to localStorage as classical: "[{},{}]"
localStorage
converts it automatially to String like "{},{}"
my current data within localStorage
:
"{"name":"volvo","id":"033"};{"name":"saab","id":"034"}"
assumption
perhaps,i can add [
at the start and ]
at the end,but it looks not gracefull
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…