Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/opendatalab-de/geojson-jackson
GeoJson POJOs for Jackson - serialize and deserialize objects with ease
https://github.com/opendatalab-de/geojson-jackson
Last synced: 4 days ago
JSON representation
GeoJson POJOs for Jackson - serialize and deserialize objects with ease
- Host: GitHub
- URL: https://github.com/opendatalab-de/geojson-jackson
- Owner: opendatalab-de
- License: apache-2.0
- Created: 2013-07-16T11:00:54.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-06-19T15:43:33.000Z (5 months ago)
- Last Synced: 2024-08-01T13:34:03.697Z (3 months ago)
- Language: Java
- Homepage: http://blog.opendatalab.de
- Size: 106 KB
- Stars: 263
- Watchers: 23
- Forks: 94
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ccamel - opendatalab-de/geojson-jackson - GeoJson POJOs for Jackson - serialize and deserialize objects with ease (Java)
README
GeoJson POJOs for Jackson
=========================A small package of all GeoJson POJOs (Plain Old Java Objects) for serializing and
deserializing of objects via JSON Jackson Parser. This libary conforms to the 2008 GeoJSON specification.Usage
-----If you know what kind of object you expect from a GeoJson file you can directly read it like this:
```java
FeatureCollection 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:
```java
GeoJsonObject object = new ObjectMapper().readValue(inputStream, GeoJsonObject.class);
if (object instanceof Polygon) {
...
} else if (object instanceof Feature) {
...
}
```
and so on.Or you can use the GeoJsonObjectVisitor to visit the right method:
```java
GeoJsonObject object = new ObjectMapper().readValue(inputStream, GeoJsonObject.class);
object.accept(visitor);
```Writing Json is even easier. You just have to create the GeoJson objects and pass them to the Jackson ObjectMapper.
```java
FeatureCollection featureCollection = new FeatureCollection();
featureCollection.add(new Feature());String json= new ObjectMapper().writeValueAsString(featureCollection);
```Maven Central
-------------You can find the library in the Maven Central Repository.
```xml
de.grundid.opendatalab
geojson-jackson
1.14```