When the front end uses sessionStorage and localStorage to store data in json format, the browser views and displays object

as the title

I saved some data by myself, and then checked it myself, which is as follows

clipboard.png

Iview

clipboard.png

I am a little strange, why I display object, others can display normally, although my object can also be normal value, but I am just curious, how to do this, do you know the boss
in addition, only json is like this, json array or json string is object
if it is just an array, it can display the corresponding value

normally.
Jun.07,2022

sessionStorage and localStorage can only save strings.
so in setItem, if it is an object, you should first JSON.stringify (). When you take it, the subject stores object, not json string, in JSON.parse ()


.
localstorage and sessionstorage theoretically basic types and reference types can be stored, but in order to avoid differences in support and performance, basic types , that is, arrays or objects, are generally converted to json strings (of course, this is not absolute, because some reference types cannot be converted directly to string types. For example, File, Stack)
has a third-party package localforage , which supports storage of any type.


localStorage.setItem ('data', JSON.stringify (object))

must be converted to a string!


1st floor correct solution, you can also write a simple compile () and uncompile () method to prevent villains


either do serialization or use a third-party package.
store.js

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb150b-69ab8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb150b-69ab8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?