// INI document static immutable string demoData = `; This is a comment. Oachkatzlschwoaf = Seriously, try pronouncing this :P [Section #1] foo = bar d = rocks ; Another comment [Section No.2] name = Walter Bright company = "Digital Mars" website = <https://digitalmars.com/> ;email = "noreply@example.org" `; // Parse the document into an associative array. auto aa = parseIniAA(demoData); assert(aa.length == 3); assert(aa[null].length == 1); assert(aa[null]["Oachkatzlschwoaf"] == "Seriously, try pronouncing this :P"); assert(aa["Section #1"].length == 2); assert(aa["Section #1"]["foo"] == "bar"); assert(aa["Section #1"]["d"] == "rocks"); string[string] section2 = aa["Section No.2"]; assert(section2.length == 3); assert(section2["name"] == "Walter Bright"); assert(section2["company"] == "Digital Mars"); assert(section2["website"] == "<https://digitalmars.com/>"); // "email" is commented out assert(!("email" in section2));
Parses an INI string into an associate array.