Index: GeoJSONBuilder.java
===================================================================
--- GeoJSONBuilder.java
+++ GeoJSONBuilder.java
@@ -23,6 +23,13 @@
 
 import java.io.Writer;
 
+import org.geotools.feature.AttributeType;
+import org.geotools.feature.Feature;
+import org.geotools.feature.FeatureCollection;
+import org.geotools.feature.FeatureIterator;
+import org.geotools.feature.FeatureType;
+import org.geotools.feature.GeometryAttributeType;
+
 
 /**
  * This class extends the JSONBuilder to be able to write out geometric types.  It is coded
@@ -59,6 +66,84 @@
     }
 
     /**
+     * Writes feature, including id, geometry and properties
+     * @param feature The feature to be encoded
+     * @return The JSONBuilder with the feature
+     * @throws JSONException
+     */
+    public JSONBuilder writeFeature(Feature feature) throws JSONException {
+    	object();
+    	
+    	key("type"); // Type field
+    	value( "Feature" );
+    	
+    	key("id"); // Id field
+    	value( feature.getID() );
+    	
+    	key("geometry"); // Feature geometry
+    	writeGeom( feature.getDefaultGeometry() );
+    	    	
+    	key("properties"); // Feature properties
+    	writeFeatureProperties( feature );
+    	
+    	return endObject();
+    }
+    
+    /**
+     * Writes feature collection
+     * @param featureCollection The feature collection to be encoded
+     * @return The JSONBuilder with the feature collection
+     * @throws JSONException
+     */
+    public JSONBuilder writeFeatureCollection( FeatureCollection featureCollection ) throws JSONException {
+    	object();
+    	
+    	key("type");
+    	value("FeatureCollection");
+    	
+    	key("features");
+    	array();
+    	
+    	FeatureIterator featureIterator = featureCollection.features(); // Iterator for features    	
+    	while ( featureIterator.hasNext() )
+    		writeFeature( featureIterator.next() );
+    	
+    	endArray();
+    	
+    	return endObject();
+    }
+    
+    /**
+     * Writes properties of feature, excluding default geometry property.
+     * @param feature The feature, which properties will be encoded
+     * @return The JSONBuilder with the feature properties
+     * @throws JSONException
+     */
+    private JSONBuilder writeFeatureProperties( Feature feature ) throws JSONException {
+    	object();
+    	
+		FeatureType featureType = feature.getFeatureType();
+		
+		for ( int i = 0; i < featureType.getAttributeCount(); ++ i ) {			
+			AttributeType attributeType = featureType.getAttributeType( i );
+			
+			// Skip default geometry type, because we always wrote it in writeFeature method
+			if ( attributeType.equals( featureType.getDefaultGeometry() ) )
+				continue;
+			
+			key( attributeType.getLocalName() );
+			
+			if ( attributeType instanceof GeometryAttributeType ) { // Geometry attribute
+				writeGeom( (Geometry) feature.getAttribute( i ) );
+			} else { // Another attributes
+				value( feature.getAttribute( i ) );
+			}
+		}
+		
+		return endObject();
+	}
+
+	/**
      * Writes any geometry object.  This class figures out which geometry representation to write
      * and calls subclasses to actually write the object.
      * @param geometry The geoemtry be encoded

