レッスン 5

Common JSON Errors 日本語ガイド

日本語の json common json errors ガイド: Trailing commas, comments, single quotes, and other frequent mistakes.

このコンテンツはまだ日本語で用意されていません。ローカライズが完了するまで English 版を表示しています。

Invalid JSON usually fails fast at parse time. Recognizing these patterns saves time when debugging API integrations or config files.

Trailing commas

{
  "a": 1,
  "b": 2,
}

JavaScript allows the comma after 2; JSON does not. Remove commas before } or ].

Single quotes

{ 'name': 'Ada' }

JSON strings must use double quotes ".

Unquoted keys

{ name: "Ada" }

Keys are strings and require double quotes: { "name": "Ada" }.

Comments

// not allowed in JSON
{ "x": 1 }

Use README files or JSON Schema descriptions for documentation—not inline comments.

Invalid literals

  • True / False — must be lowercase true / false
  • undefined — omit the property or use null
  • NaN, Infinity — not valid JSON numbers

Smart quotes and invisible characters

Copying from Word or web pages may insert " " instead of ". Editors may add BOM or non-breaking spaces. If parsing fails with a cryptic position error, re-type quotes or paste through a plain-text editor.

Almost-JSON from JavaScript

When developers log objects or copy from browser consoles, output may look like JSON but include functions, undefined, or unquoted keys. Always run through a strict parser before treating text as JSON.

Fixing workflow

  1. Read the parser error line and column.
  2. Check the line above closing brackets for extra commas.
  3. Verify all strings and keys use ".
  4. Remove comments and JavaScript-only syntax.

These rules are strict by design—strictness is what makes JSON portable across systems.

実践したいときは関連する DevCove ツールを使えます。任意であり、このレッスンの必須部分ではありません。

関連ツールを開く

コース概要へ戻る