filosganga / geogson

GeoJSON support for Google gson library
Apache License 2.0
69 stars 28 forks source link

Bug in strictness of parsing #60

Open bkrahmer opened 6 years ago

bkrahmer commented 6 years ago

Hi. I was checking out your library, and I think I found a bug in the strictness of the parsing. This case should throw an exception: String geojson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\","+ "\"geometry\":{\"type\":\"Point\",\"coordinates\":["+ "-72.08541870117188,-39.25139776900491]}}]}"; Gson gson = new GsonBuilder().registerTypeAdapterFactory(new GeometryAdapterFactory()).create(); FeatureCollection fc = gson.fromJson(geojson, FeatureCollection.class);

However, it does not. The reason that I believe it should is the https://tools.ietf.org/html/rfc7946#section-3 In section 3.2 it says: A Feature object has a member with the name "properties". The value of the properties member is an object (any JSON object or a JSON null value). http://geojson.io rejects this json as well. It doesn't directly impact me right now, but I thought you might want to fix that if possible (not certain if you can).

thanks, brian

filosganga commented 6 years ago

Hi, I agree with your point. However, many third-party softwares out there do not respect the RFC at all.

I think having this relaxed parser does not cause any harm. We may introduce a flag to make it more strict, but I don't believe it is a priority right now.

thanks for your feedback.