docs: function (obj) {
      var i, out='{', comma='';
      for (i in obj) {
        if (obj.hasOwnProperty(i)) {
          if (!i.match(/^[a-z0-9]+$/i)) {
            throw new sjcl.exception.invalid("json encode: invalid property name");
          }
          out += comma + '"' + i + '":';
          comma = ',';
  
          switch (typeof obj[i]) {
            case 'number':
            case 'boolean':
              out += obj[i];
              break;
  
            case 'string':
              out += '"' + escape(obj[i]) + '"';
              break;
  
            case 'object':
              out += '"' + sjcl.codec.base64.fromBits(obj[i],0) + '"';
              break;
  
            default:
              throw new sjcl.exception.bug("json encode: unsupported type");
          }
        }
      }
      return out+'}';
    }