16

I am creating a Java web service that receives GeoJSON.

Does anyone know a java library to manage GeoJSON?

2
  • 1
    You need to give a bit more information about what you want to do with the incoming GeoJSON. Commented Jan 20, 2015 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
    Commented Jan 20, 2015 at 10:39

3 Answers 3

12

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.

1
7

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

2
  • 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? Commented Jun 17, 2015 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
    Commented Jun 17, 2015 at 20:26
7

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]}");
1
  • This works like a charm! It's perfectly compatible with Android as well.
    – xarlymg89
    Commented Nov 2, 2018 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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