Open Sil0x0000 opened 7 years ago
I'm not familiar with the AUTO_DETECT_GETTERS option. The geojson objects use the standard bean convention. Can you give an example how you handle your JSON objects?
This is a feature of jackson to change the default behaviour of attribute detection. when this feature is not enabled (set to false) then there is need for explicitly identify which fields (or getter methods) are exposed through jackson serilization. I attached an exmaple:
Test.java
package test;
import org.geojson.Point;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
public class TestGeoJson {
private Point p1 = new Point(1.0, 10.0);
public static void main(String[] args) throws Exception {
new TestGeoJson().test();
}
public void test() throws Exception {
String json = getMapper().writeValueAsString(p1);
System.out.println(json);
Point copy = getMapper().readValue(json, Point.class);
System.out.println(p1.equals(copy));
}
public ObjectMapper getMapper() {
ObjectMapper m = new ObjectMapper();
m.configure(MapperFeature.AUTO_DETECT_GETTERS, false);
return m;
}
}
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>geo-json-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<jackson.version>2.8.9</jackson.version>
</properties>
<dependencies>
<dependency>
<groupId>de.grundid.opendatalab</groupId>
<artifactId>geojson-jackson</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
</project>
Note: my request is a feature request not a bug.
When I try to use geojson-jackson it doesn't de serialize coordinates from point (for example when the default mapper feature AUTO_DETECT_GETTERS is set to false.
Is it possible to make geojson-jackson such that it also works when the this mapper setting is put diffrent then the default?
Best regards