How to convert a simple INI file contents into JSON? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to convert a simple INI file contents into JSON?

For a future project, I am planning to make some IDE-like program dealing with INI files. Probably Python or JavaScript

31st Aug 2021, 7:26 AM
G-Man
G-Man - avatar
2 Answers
+ 3
If you are using nodejs, check out the `ini` package on npm: const fs = require('fs'); const ini = require('ini'); const file = fs.readFileSync('./config.ini', 'utf-8'); const parsed = ini.parse(file); const json = JSON.stringify(parsed); console.log(json);
31st Aug 2021, 7:32 AM
Schindlabua
Schindlabua - avatar
+ 3
Found one in Github, for Python. Maybe you can extend from it. https://gist.github.com/Natim/4509560
31st Aug 2021, 7:43 AM
Ipang