# Class: GeoJSON

## GeoJSON

Feature format for reading and writing data in the GeoJSON format.

#### new ol.format.GeoJSON(opt_options) experimental

src/ol/format/geojsonformat.js, line 32

  Name | Type | Description
  --- | --- | ---
  `options` | optional Options.
  Name | Type | Description
  --- | --- | ---
  `defaultProjection` | ol.proj.ProjectionLike | Default projection.
  `geometryName` | string | undefined | optional Geometry name to use when creating features.

### Extends

- ol.format.JSONFeature

### Methods

#### readFeature(source){ol.Feature} experimental

src/ol/format/geojsonformat.js, line 336

  Read a feature from a GeoJSON Feature source. This method will throw an error if used with a FeatureCollection source.

  Name | Type | Description
  --- | --- | ---
  `source` | ArrayBuffer | Document | Node | Object | string | Source.

  ##### Returns:

  Feature.

#### readFeatures(source){Array.<ol.Feature>} experimental

src/ol/format/geojsonformat.js, line 348

  Read all features from a GeoJSON source. Works with both Feature and FeatureCollection sources.

  Name | Type | Description
  --- | --- | ---
  `source` | ArrayBuffer | Document | Node | Object | string | Source.

  ##### Returns:

  Features.

#### readGeometry(source){ol.geom.Geometry} experimental

src/ol/format/geojsonformat.js, line 406

  Read a geometry from a GeoJSON source.

  Name | Type | Description
  --- | --- | ---
  `source` | ArrayBuffer | Document | Node | Object | string | Source.

  ##### Returns:

  Geometry.

#### readProjection(object){ol.proj.Projection} experimental

src/ol/format/geojsonformat.js, line 425

  Read the projection from the GeoJSON source file.

  Name | Type | Description
  --- | --- | ---
  `object` | ArrayBuffer | Document | Node | Object | string | Source.

  ##### Returns:

  Projection.

#### writeFeature(feature){ArrayBuffer|Node|Object|string} experimental

src/ol/format/geojsonformat.js, line 455

  Encode a feature as a GeoJSON Feature object.

  Name | Type | Description
  --- | --- | ---
  `feature` | ol.Feature | Feature.

  ##### Returns:

  Result.

#### writeFeatures(features){ArrayBuffer|Node|Object|string} experimental

src/ol/format/geojsonformat.js, line 491

  Encode an array of features as GeoJSON.

  Name | Type | Description
  --- | --- | ---
  `features` | Array.<ol.Feature> | Features.

  ##### Returns:

  Result.