34
17

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 5 years have passed since last update.

JSON.parse()で発生したエラーの対処法(Uncaught SyntaxError: Unexpected end of JSON input)

Posted at

エラー内容

Uncaught SyntaxError: Unexpected end of JSON input

JSON.parse()で発生したエラー。
原因として多いのは()などの閉じ忘れだが、今回はJSON.parse()の記述に問題があった。

修正前 JSON.parse(data)
修正後 JSON.parse(data || "null")

空文字があると上記のエラーが発生するらしい。

34
17
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
34
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?