11

I am creating a Java web service that receives GeoJSON.

Does anyone know a java library to manage GeoJSON?

  • 1
    You need to give a bit more information about what you want to do with the incoming GeoJSON. – John Powell Jan 20 '15 at 10:35
  • For now only read the geometry and properties . I know you can treat a GeoJSON as a JSON , only that I preferred to use a library to avoid errors.I was hoping that there was already instead of having to write it myself. – Djacomo Jan 20 '15 at 10:39
11

Geotools as a support for geojson. See here.

Otherwise, you could simply use a typical JSON parser (such as json-simple) together with the geoJSON spec, which is really easy to use.

The best solution depends on what you want to do with the parsed information.

7

To parse or deserialize geojson in Java REST webservice, i prefere to use geojson-jackson , which integrate itself very nicely with jackson.

  • I'm trying to use that library but I can't find any documentation on how to use it. Do you know where I can find some? – Kyle Bridenstine Jun 17 '15 at 19:07
  • yes there's no doc apart the Readme page in github, but i think that page is enough, what's you need to know to use that library ? – geogeek Jun 17 '15 at 20:26
4

Another alternative is GeoGson, which is built on top of Google's Gson:

Geometry geometry = new GsonBuilder()
        .registerTypeAdapterFactory(new GeometryAdapterFactory())
        .create()
        .fromJson("{\"type\":\"Point\",\"coordinates\": [23.5,20.125]}");
  • This works like a charm! It's perfectly compatible with Android as well. – xarlymg89 Nov 2 '18 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.