code: function(obj, pretty) {
          var geojson = {
              "type": null
          };
          if(OpenLayers.Util.isArray(obj)) {
              geojson.type = "FeatureCollection";
              var numFeatures = obj.length;
              geojson.features = new Array(numFeatures);
              for(var i=0; i<numFeatures; ++i) {
                  var element = obj[i];
                  if(!element instanceof OpenLayers.Feature.Vector) {
                      var msg = "FeatureCollection only supports collections " +
                                "of features: " + element;
                      throw msg;
                  }
                  geojson.features[i] = this.extract.feature.apply(
                      this, [element]
                  );
              }
          } else if (obj.CLASS_NAME.indexOf("OpenLayers.Geometry") == 0) {
              geojson = this.extract.geometry.apply(this, [obj]);
          } else if (obj instanceof OpenLayers.Feature.Vector) {
              geojson = this.extract.feature.apply(this, [obj]);
              if(obj.layer && obj.layer.projection) {
                  geojson.crs = this.createCRSObject(obj);
              }
          }
          return OpenLayers.Format.JSON.prototype.write.apply(this,
                                                              [geojson, pretty]);
      }
docs: APIMethod: write
  Serialize a feature, geometry, array of features into a GeoJSON string.
  
  Parameters:
  obj - {Object} An <OpenLayers.Feature.Vector>, <OpenLayers.Geometry>,
  or an array of features.
  pretty - {Boolean} Structure the output with newlines and indentation.
  Default is false.
  
  Returns:
  {String} The GeoJSON string representation of the input geometry,
  features, or array of features.