---
title: "GeoJSON Serializer"
version: 1.9
locale: pt-br
source: https://docs.djangoproject.com/pt-br/1.9/ref/contrib/gis/serializers/
canonical: https://djangodocs.dev/pt-br/1.9/ref/contrib/gis/serializers/
---
# `GeoJSON` Serializer

> **New in Django 1.8**

GeoDjango provides a specific serializer for the [GeoJSON](http://geojson.org/) format. See
[Serializing Django objects](/pt-br/1.9/topics/serialization/) for more information on serialization.

The GDAL library is required if any of the serialized geometries need
coordinate transformations (that is if the geometry’s spatial reference system
differs from the `srid` serializer option).

> **Changed in Django 1.9**
>
> The GeoJSON serializer no longer needs GDAL if all geometries are in the
> same coordinate system as the `srid` serializer option.

The `geojson` serializer is not meant for round-tripping data, as it has no
deserializer equivalent. For example, you cannot use [`loaddata`](/pt-br/1.9/ref/django-admin/#django-admin-loaddata) to
reload the output produced by this serializer. If you plan to reload the
outputted data, use the plain [json serializer](/pt-br/1.9/topics/serialization/#serialization-formats-json)
instead.

In addition to the options of the `json` serializer, the `geojson`
serializer accepts the following additional option when it is called by
`serializers.serialize()`:

- `geometry_field`: A string containing the name of a geometry field to use
  for the `geometry` key of the GeoJSON feature. This is only needed when you
  have a model with more than one geometry field and you don’t want to use the
  first defined geometry field (by default, the first geometry field is picked).
- `srid`: The SRID to use for the `geometry` content. Defaults to 4326
  (WGS 84).

The [fields](/pt-br/1.9/topics/serialization/#subset-of-fields) option can be used to limit fields that
will be present in the `properties` key, as it works with all other
serializers.

Exemplo

```
from django.core.serializers import serialize
from my_app.models import City

serialize('geojson', City.objects.all(),
          geometry_field='point',
          fields=('name',))
```

Would output:

```
{
  'type': 'FeatureCollection',
  'crs': {
    'type': 'name',
    'properties': {'name': 'EPSG:4326'}
  },
  'features': [
    {
      'type': 'Feature',
      'geometry': {
        'type': 'Point',
        'coordinates': [-87.650175, 41.850385]
      },
      'properties': {
        'name': 'Chicago'
      }
    }
  ]
}
```
