parseObject(text: string): Promise<Record<string, Record<string, unknown>>>
Parse an INI string into an object.
Since it returns an object, it does not support duplicate keys or sections. If duplicates exist, later values overwrite earlier ones. This is the reverse of stringifyObject and uses parseArray under the hood.
The global section (entries before any [section] header) is stored under
the empty string key "".
Parse INI to object
Parse INI to object
import { parseObject } from "@hertzg/wg-ini"; import { assertEquals } from "@std/assert"; const text = [ "global_key=global_value", "", "[mysection]", "key1=1", "key2=2", "", ].join("\n"); assertEquals(await parseObject(text), { "": { global_key: "global_value" }, mysection: { key1: "1", key2: "2" }, });