INI : INI parser and encoder

更新时间:
2024-03-04
下载文档

INI : INI parser and encoder

This module is an INI format parsing module, similar to the JavaScript built-in JSON object.

This module has been built-in in JSRE and does not require require() to import.

Example

var fs = require('fs');

var obj = {
  section1: {
    key1: '111'
  },
  section2: {
    key1: '1111',
    key2: '2222'
  }
};

var str = INI.stringify(obj);

fs.writeFile('./test.ini', str);
var fs = require('fs');

var str = fs.readString('./test.ini');

var obj = INI.parse(str);

console.log('ini obj:', obj);

Support

The following shows INI module APIs available for each permissions.

 User ModePrivilege Mode
INI.parse
INI.stringify

INI Object

INI.parse(iniString)

  • iniString {String} INI format string.
  • Returns: {Object} Convert to object.

Parse the specified INI string and return the result object.

Similar to JSON.parse().

INI.stringify(obj[, replacer[, space]])

  • obj {Object} Object to be convert.
  • replacer {Function} | {Array} Unsupport now.
  • space {String} Add indents spaces. default: ''.
  • Returns: {String} INI format string.

Convert specified object to INI format string. space can be: '', ' ', '\t'.

Similar to JSON.stringify().

文档内容是否对您有所帮助?
有帮助
没帮助