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?

More than 3 years have passed since last update.

JSONとは

Posted at

JSON

表記はjavascriptのオブジェクトに似ているが、JSONはオブジェクトではなく文字列になる。

JSONの変換メソッド

  • JSON.parse
    • JSON => Objectへ変換
  • JSON.stringify
    • Object => JSONへ変換

const obj = {a: 0, b: 1, c: 2};

const json = JSON.stringify(obj)
console.log(typeof json)

>>> string


const obj2 = JSON.parse(json)
console.log(typeof obj2)

>>> object

ストレージなどにデータを保存する場合はJSON形式になるので変換メソッドはよく使う。

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?