Skip to content

Json5ConfigSerializer

IConfigSerializer for the JSON5 format (JSON with comments). Archie's default on Fabric.

Functions

configPath

open override fun configPath(config: ConfigSpec, configFolder: Path): Path

File the given config is read from and written to, resolved under configFolder.

load

open fun load(config: ConfigSpec, configFolder: Path = Platform.getConfigFolder())

Reads config's file if present via loadString, then always saves it back out - this both formats a freshly-created file with defaults and rewrites an existing one with any newly-added fields. If the existing file fails to parse, it's logged and renamed to <file>.corrupted rather than deleted, and loading falls through to writing fresh defaults so startup isn't blocked.

loadString

open override fun loadString(config: ConfigSpec, string: String)

Parses string and populates config's fields from it. Implemented per-format.

save

open fun save(config: ConfigSpec, configFolder: Path = Platform.getConfigFolder())

Writes config's current field values to configPath, creating parent directories as needed.

saveString

open override fun saveString(config: ConfigSpec): String

Renders config's current field values as a file-format string. Implemented per-format.