Unablel to save geopoints with ecto3.0 +

Hi ,
I am using all latest devendencies ecto, postgres and I am trying to save geo points in the table but I am getting

** (Protocol.UndefinedError) protocol Jason.Encoder not implemented for %Geo.Point{coordinates: {30, -90}, properties: %{}, srid: 4326}, Jason.Encoder protocol must always be explicitly implemented.

the above error

I am using this geo_postgis library : https://github.com/bryanjos/geo_postgis

:wave:

You might need to set Jason here https://github.com/bryanjos/geo_postgis#optional-configuration

And also when defining the types:

Postgrex.Types.define(MyApp.PostgresTypes,
  [Geo.PostGIS.Extension] ++ Ecto.Adapters.Postgres.extensions(),
  json: Jason) # <-----
1 Like

Yep, still doesn’t work!!

:slightly_frowning_face:

Can you create a small repo on github that reproduces the problem?

After changing the configuration of :geo_postgis, have you recompiled geo_postgis? The easiest way to do so is to mix deps.compile geo_postgis --force, if that doesn’t work, please try rm -rf _build deps; mix do deps.get, deps.compile.

You should review the docs of Jason and Geo.Postgis, I’ve followed then and was sorted in a few minutes.

Failing that, give us a small GitHub repo so we can review.

@idiot I will get back to you guys with a github repo

@idiot @dimitarvp @NobbZ Thanks guys. I just did everything from the scratch and it worked for me :slight_smile: