StoicBuilder

HandbookI the LudusJSON

Ithe Ludus, Read code

JSON

1 min readUpdated 28 November

In plain words

JSON is a plain-text way of writing objects and arrays, so data can travel between your browser, your server and services like Stripe or Supabase.

Where you see it

Open the Network tab in your browser's dev tools, click a request, and the response is JSON. Your package.json is JSON too, which is why one stray comma in it can stop the whole project from installing.

package.jsonconfig
{ "name": "quill", "private": true, "scripts": { "dev": "vite", "build": "vite build" }}
Keys in double quotes, no comments, no comma after the last item.

What goes wrong

  1. A trailing comma or a comment

    JSON is stricter than JavaScript. A comma after the last item or a // comment makes the file invalid, and npm refuses to run.

    { "dev": "vite", }
  2. Parsing an error page as JSON

    When an API route fails, it often sends back an HTML page. res.json() then throws "Unexpected token '<'", because HTML starts with <.

  3. Dates arriving as text

    JSON has no date type, so a date travels as a string like "2026-12-05T09:00:00Z". Code that calls date methods on it without converting first breaks.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Before calling res.json(), check res.ok. When the request fails, log the status code and the raw response text, so the real problem shows up instead of a JSON parse error.

Quick check

Sign in to earn +10 XP for it

Your app crashes with "Unexpected token '<', "<!DOCTYPE "... is not valid JSON". What did the server send?

Got a prompt that touches JSON?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.