I was trying to deserialize a JSON string that contains a GeoJSON string.
point: {
type: "Point",
coordinates: [
7.779259,
52.21864
]
}
The object I want to create is of type
com.vividsolutions.jts.geom.Point
We use this class because of the use of an PostGis database for spatial data. Unfortunately the class does not have a non-arg constructor, which is needed. But somehow it also implements CoordinateSequence CoordinateSequence which neither has a non-arg constructor. Whenever I try to deserialize the incoming json string I get an error
java.lang.RuntimeException: Unable to invoke no-args constructor for
interface com.vividsolutions.jts.geom.CoordinateSequence.
Register an InstanceCreator with Gson for this type may fix this problem.
I tried to create an InstanceCreator for the interface of CoordinateSequence following the example here but did not succeed. Also subclassing Point did not bring the answer as the problem lies in the used interface of CoordinateSequence.
I would be thankful for any help or hints, that lead me to the solution.