DAI 4.1 · LEVEL 0 · CHAPTER 3

JSON From Zero

Learn the JSON syntax DAI uses, how to read nested definitions, and how to fix the most common syntax failures.

No coding experience requiredCopyable examplesDAI 4.1

JSON is structured data, not mysterious code.

DAI uses JSON to describe things: actions, entities, items, experiences, UI, rules and more. JSON does not “run” by itself; DAI or Minecraft reads it and interprets the fields.

The six pieces you need first

SyntaxNameMeaning
{ }ObjectA group of named fields.
[ ]ArrayAn ordered list of values.
"text"StringText, including IDs and names.
42NumberNumeric value; no quotes.
true / falseBooleanOn/off or yes/no value; no quotes.
: and ,SeparatorsColon joins a key to its value; comma separates entries.

Read this one field at a time

data/my_first_dai/logics/definitions/hello.json
{
  "type": "sequence",
  "sequence": [
    {
      "type": "run_command",
      "action": "say Hello from my DAI pack"
    }
  ]
}
  1. The outer { }contains one DAI definition.
  2. "type": "sequence"says the definition contains ordered actions.
  3. "sequence": [ ]is a list.
  4. The inner { }is one action in that list.
  5. run_commandtells DAI which action primitive to use.

Commas: the most common first error

Valid

{
  "name": "Example",
  "enabled": true,
  "cost": 5
}

Invalid trailing/missing comma

{
  "name": "Example"
  "enabled": true,
  "cost": 5,
}

Strings must use double quotes

Standard JSON uses double quotes. 'single quotes' are not valid JSON strings. Do not add comments such as // note inside ordinary JSON unless a specific loader explicitly supports them.

IDs are usually strings

"my_game:hello" is a string containing a namespaced ID. Treat IDs like permanent addresses: change display text freely, but avoid changing stable IDs after release.

How to edit safely

  1. Start from a known-good example.Copy the closest documented definition.
  2. Change one field.Do not rewrite ten things before testing.
  3. Validate JSON.DAI Creator validation or a code editor can catch syntax before Minecraft reloads.
  4. Reload and test.Syntax-valid JSON can still contain wrong IDs or unsupported values.

Error translation

Message familyWhat to inspect first
Expected comma / delimiterTwo entries are touching or a comma is misplaced.
Unexpected end of inputA closing } or ] is probably missing.
Expected property nameA key may be unquoted, malformed, or preceded by an extra comma.
Unknown action/typeThe JSON parsed, but DAI does not know the requested ID/type.
Missing referenceThe file points to another ID/path that does not exist.

Checkpoint

You are ready when you can identify an object, array, string and boolean and can fix a missing comma without guessing.

Continue into DAI 4.1

How-To Guide Index · Complete 4.1 Capabilities