Name: geojson-jackson
Owner: OpenDataLab
Description: GeoJson POJOs for Jackson - serialize and deserialize objects with ease
Created: 2013-07-16 11:00:54.0
Updated: 2018-02-16 16:08:22.0
Pushed: 2018-01-05 18:10:49.0
Homepage: http://blog.opendatalab.de
Size: 88
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A small package of all GeoJson POJOs (Plain Old Java Objects) for serializing and deserializing of objects via JSON Jackson Parser.
If you know what kind of object you expect from a GeoJson file you can directly read it like this:
ureCollection featureCollection =
new ObjectMapper().readValue(inputStream, FeatureCollection.class);
If you want to read any GeoJson file read the value as GeoJsonObject and then test for the contents via instanceOf:
sonObject object = new ObjectMapper().readValue(inputStream, GeoJsonObject.class);
object instanceof Polygon) {
...
se if (object instanceof Feature) {
...
and so on.
Or you can use the GeoJsonObjectVisitor to visit the right method:
sonObject object = new ObjectMapper().readValue(inputStream, GeoJsonObject.class);
ct.accept(visitor);
Writing Json is even easier. You just have to create the GeoJson objects and pass them to the Jackson ObjectMapper.
ureCollection featureCollection = new FeatureCollection();
ureCollection.add(new Feature());
ng json= new ObjectMapper().writeValueAsString(featureCollection);
You can find the library in the Maven Central Repository.
endency>
oupId>de.grundid.opendatalab</groupId>
tifactId>geojson-jackson</artifactId>
rsion>1.8</version>
pendency>