Skip to content

Commit

Permalink
Prevent Jackson from marshalling "type" property twice
Browse files Browse the repository at this point in the history
  • Loading branch information
peder280370 committed Jun 27, 2017
1 parent 8be3218 commit 423678c
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -15,6 +15,7 @@
*/
package org.niord.model.geojson;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -37,8 +38,6 @@
PolygonVo.class, MultiPolygonVo.class, GeometryCollectionVo.class, FeatureVo.class, FeatureCollectionVo.class
}
)
// TODO: Re-introduce include=EXISTING_PROPERTY - disabled for now because of clients with old Jackson versions :-(
// @JsonTypeInfo(property = "type", use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY)
@JsonTypeInfo(property = "type", use = JsonTypeInfo.Id.NAME)
@JsonSubTypes({
@JsonSubTypes.Type(value = PointVo.class, name = "Point"),
Expand Down Expand Up @@ -120,6 +119,7 @@ public double[] computeCenter() {
return new double[]{(bbox[0] + bbox[2]) / 2.0, (bbox[1] + bbox[3]) / 2.0};
}

@JsonIgnore // @JsonTypeInfo will add the "type" property as a discriminator field
public String getType() {
return type;
}
Expand Down

0 comments on commit 423678c

Please sign in to comment.