Cannot parse a valid GeoJSON string via readValue(geoJson, GeoJsonObject.class);.
Here is the code to reproduce the exception:
String geoJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-126.456789,-2.123,0.0],[-123.456789,2.123,0.0],[-124.456789,2.123,0.0],[-125.456789,-2.123,0.0],[-126.456789,-2.123,0.0]]]},\"properties\":{\"myProp\":\"PropData1\"}},{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-123.123,55.555,0.0]},\"properties\":{\"myProp\":\"PropData2\"}},{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[123.456789,2.123,0.0],[-123.456789,2.123,0.0],[-124.456789,2.123,0.0],[-125.456789,-2.123,0.0],[123.456789,2.123,0.0]]]},\"properties\":{\"myProp\":\"PropData3\"}},{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-15.123,75.555,0.0]},\"properties\":{\"myProp\":\"PropData4\"}}]}";
GeoJsonObject object = new ObjectMapper().readValue(geoJson, GeoJsonObject.class);
The log is the next:
Can not construct instance of org.geojson.GeoJsonObject, problem: abstract types can only be instantiated with additional type information
at [Source: java.io.StringReader@aa0657b; line: 1, column: 1]
org.codehaus.jackson.map.JsonMappingException: Can not construct instance of org.geojson.GeoJsonObject, problem: abstract types can only be instantiated with additional type information
at [Source: java.io.StringReader@aa0657b; line: 1, column: 1]
at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)
at org.codehaus.jackson.map.deser.StdDeserializationContext.instantiationException(StdDeserializationContext.java:233)
at org.codehaus.jackson.map.deser.AbstractDeserializer.deserialize(AbstractDeserializer.java:60)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2732)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863)
For convince here is the geoJson which I try to parse:
Cannot parse a valid GeoJSON string via
readValue(geoJson, GeoJsonObject.class);
.Here is the code to reproduce the exception:
The log is the next:
For convince here is the
geoJson
which I try to parse: