function encode(obj, opt) {
        var children = []
        var out = ''

        if (typeof opt === 'string') {
          opt = {
            section: opt,
            whitespace: false
          }
        } else {
          opt = opt || {}
          opt.whitespace = opt.whitespace === true
        }

        var separator = opt.whitespace ? ' = ' : '='

        Object.keys(obj).forEach(function(k, _, __) {
          var val = obj[k]
          if (val && Array.isArray(val)) {
            val.forEach(function(item) {
              out += safe(k + '[]') + separator + safe(item) + '\n'
            })
          } else if (val && typeof val === 'object') {
            children.push(k)
          } else {
            out += safe(k) + separator + safe(val) + eol
          }
        })

        if (opt.section && out.length) {
          out = '[' + safe(opt.section) + ']' + eol + out
        }

        children.forEach(function(k, _, __) {
          var nk = dotSplit(k).join('\\.')
          var section = (opt.section ? opt.section + '.' : '') + nk
          var child = encode(obj[k], {
            section: section,
            whitespace: opt.whitespace
          })
          if (out.length && child.length) {
            out += eol
          }
          out += child
        })

        return out
      }
Set up state for next re-rendering