You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@rlidwka Your example is a valid weirdness. Patch welcome.
@avasin Your first example is working as intended. Your second example is weird and I am not sure what the correct behavior is. Can you please post separate issues for what you expect the (2) case to do? It's not related to @rlidwka's issue.
This is my solution, seems to be working to flatten it back as expected:
/** * Reduce the nested object back to a flat object by concatenating object keys with a `.` * @param obj Nested object * @returns {{}} */functionflattenIniObject(obj){function_flattenIniObject(obj,topLevel=[],resp={}){letprops={};for(letkeyinobj){if(typeofobj[key]=='object'){topLevel.push(key);resp={ ...resp, ..._flattenIniObject(obj[key],topLevel,resp)}}elseprops[key]=obj[key];}consttopLevelName=topLevel.join(".");if(topLevelName!==''&&Object.keys(props).length>0)resp={ ...resp,[topLevelName]: props}topLevel.pop();returnresp;}return_flattenIniObject(obj);}letiniData=ini.parse(`; config.ini[file1.jpg]size=10date=2014[file2.jpg]size=11date=2013[other-file2.jpg]size=10date=2012; extra test cases[file1]strange=but okay[level_1]data=level 111[level_1.level_2]data=level 222[level_1.level_2.level_3]data=level 333cool=yes`)constflat=flattenIniObject(iniData);console.log(flat)
i think dots should not be used as separators if they are part of a quoted string in a section header...
and if i understand the most comments here correctly that is the main point?!
Activity
alvassin commentedon May 21, 2014
+1
Example №1
will return
Example №2
Will return
undefined. Guys, your package is working well, it has cool name, and is very popular. Please add such support.isaacs commentedon May 21, 2014
@rlidwka Your example is a valid weirdness. Patch welcome.
@avasin Your first example is working as intended. Your second example is weird and I am not sure what the correct behavior is. Can you please post separate issues for what you expect the (2) case to do? It's not related to @rlidwka's issue.
alvassin commentedon May 21, 2014
@isaacs hm.. i expected to get deep parsed object in the first example:
Second example behaviour is expected to be the same as described here - deep object parsing.
mycaule commentedon May 26, 2014
I would like to access a file with variable filenames sections. It would be nice to access the object with quotes.
You need to comment lines 101-120 to do this. One possible feature should be to be able to disable this with an option when invoking
inipackage.rlidwka commentedon Jun 17, 2014
@mycaule , that's not how ini works. All ini parsers treat dots as path separators, and not doing so would be incompatible.
Instead, I would suggest to use this syntax:
This module doesn't support it, but I've seen parsers in other languages that do.
I implemented it here, can provide a patch if someone is interested.
mycaule commentedon Jun 20, 2014
I have never seen a dot in a Windows config file section used that way.
And this doesn't seem standard at all.
I think it is more like a hack to do some sort of mapping between JSON and INI.
p3k commentedon Sep 18, 2019
i cannot find this in the spec anywhere… is this something that evolved as a quasi-standard? is the statement really true for all ini parsers?
the idea to use a filename for the section key does seem legit. but this package makes parsing such
inifiles cumbersome at the very least.rehanvdm commentedon Feb 11, 2023
This is my solution, seems to be working to flatten it back as expected:
Outputs:

s-light commentedon Apr 23, 2025
i think dots should not be used as separators if they are part of a quoted string in a section header...
and if i understand the most comments here correctly that is the main point?!
.gitmodulesthe first is working
the second ist split up: