0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【javascript】【jquery】ローカルストレージで取得した配列をjson形式にしたい

Last updated at Posted at 2024-06-01

ローカルストレージで取得

 var data = localStorage.getItem('local_data');

ローカルストレージの中身

var data = {"chara":["34","37","39"],"dragon":["6","8","32"],"skill":{"chara_34":4,"chara_37":3,"chara_39":4,"dragon_6":4}}

のような配列

そのままでは使えない

data = JSON.parse(data);

で使えるようにする

console.log(data.skill)

結果

{"chara_34":4,"chara_37":3,"chara_39":4,"dragon_6":4}

参考
https://www.digitalocean.com/community/tutorials/js-json-parse-stringify-ja

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?