var bops = require('bops')

//TODO: handle reviver/dehydrate function like normal
//and handle indentation, like normal.
//if anyone needs this... please send pull request.

exports.stringify = function stringify (o) {
  if(o && bops.is(o))
    return JSON.stringify(':base64:' + bops.to(o, 'base64'))

  if(o && o.toJSON)
    o =  o.toJSON()

  if(o && 'object' === typeof o) {
    var s = ''
    var array = Array.isArray(o)
    s = array ? '[' : '{'
    var first = true

    for(var k in o) {
      var isFunction = 'function' == typeof o[k]
      if(Object.hasOwnProperty.call(o, k) && o[k] !== void(0) && !isFunction) {
        if(!first)
          s += ','
        first = false
        s += array ? stringify(o[k]) : stringify(k) + ':' + stringify(o[k])
      }
    }

    s += array ? ']' : '}'

    return s
  } else if ('string' === typeof o) {
    return JSON.stringify(/^:/.test(o) ? ':' + o : o)
  } else 
    return JSON.stringify(o)
}

exports.parse = function (s) {
  return JSON.parse(s, function (key, value) {
    if('string' === typeof value) {
      if(/^:base64:/.test(value))
        return bops.from(value.substring(8), 'base64')
      else
        return /^:/.test(value) ? value.substring(1) : value 
    }
    return value
  })
}

@@ -587,28 +587,8 @@
 ) &&
- o%5Bk%5D !== void(0) &&
  !is
@@ -671,38 +671,105 @@
     
-s += array ? stringify(o%5Bk%5D) :
+if (array) %7B%0A          s += stringify(o%5Bk%5D)%0A        %7D else if (o%5Bk%5D !== void(0)) %7B%0A          s +=
  str
@@ -798,24 +798,34 @@
 ngify(o%5Bk%5D)%0A
+        %7D%0A
       %7D%0A    
@@ -960,16 +960,76 @@
  o : o)%0A
+  %7D else if ('undefined' === typeof o) %7B%0A    return 'null';%0A
   %7D else

undefineds in arrays should be null