1
Text Format
GigabiteStudios edited this page 2026-06-17 19:04:13 -05:00

Text Format

Canonical document

ikv2 "player_save"
{
    "title" "iKv demo"
    "version" 2
    "enabled" true
    "speed" 12.5
    "player" {
        "name" "Ada"
        "note" "line one\nline two"
    }
    "inventory" [
        "wrench"
        "battery"
        "map"
    ]
}

The normal header is:

ikv<version> <root-name>

The root name may be quoted or a bare word when parsing. Writers always emit a quoted name and use "root" if the in-memory root name is empty.

Informal grammar

document      := versioned-object | object | plain-members
versioned-object := ("ikv1" | "ikv2") root-name object
object        := "{" { member [","] } "}"
member        := quoted-string value
array         := "[" { value [","] } "]"
value         := object | array | quoted-string | word
root-name     := quoted-string | word
plain-members := { member [","] }

Commas are optional between object members and array elements. Whitespace separates adjacent values.

Keys and strings

Object keys must be quoted strings. Supported escapes are:

Escape Result
\\ Backslash
\" Double quote
\n Newline
\r Carriage return
\t Tab

Other backslash sequences are retained literally rather than interpreted as Unicode or hexadecimal escapes. The current format does not implement \uXXXX escapes.

Bare-word inference

Unquoted words are interpreted in this order:

  1. true or false → boolean
  2. null → null
  3. A complete numeric token containing ., e, or E → float
  4. A complete base-10 numeric token → signed integer
  5. Anything else → string

Examples:

{
    "a" true
    "b" -42
    "c" 6.25
    "d" 1e6
    "e" unquoted-string
}

Writers quote all strings, so generated files do not rely on bare-string inference.

Comments

Two line-comment forms are supported outside strings:

// C++ style comment
# shell style comment

Each runs through the end of the line. Block comments are not supported.

Alternate accepted roots

The parser also accepts an unversioned braced object:

{
    "name" "demo"
}

Or plain top-level members:

"name" "demo"
"count" 3

Versioned output is recommended because it is explicit and is what the writer produces for object roots.

Formatting behavior

  • Writers indent nested values by four spaces.
  • Floating-point values use up to 17 significant digits.
  • Arrays and objects are written over multiple lines.
  • Object member order is not guaranteed.
  • An object root receives a version header; a non-object C root is written as a bare value.