diff --git a/src/GeoJSON.Net.Tests/Feature/FeatureTests.cs b/src/GeoJSON.Net.Tests/Feature/FeatureTests.cs index 07259f9..1f1c2a1 100644 --- a/src/GeoJSON.Net.Tests/Feature/FeatureTests.cs +++ b/src/GeoJSON.Net.Tests/Feature/FeatureTests.cs @@ -29,6 +29,20 @@ public void Can_Deserialize_Point_Feature() Assert.AreEqual(GeoJSONObjectType.Point, feature.Geometry.Type); } + [Test] + public void Can_Deserialize_Feature_Without_Props() + { + var json = GetExpectedJson(); + + var feature = JsonConvert.DeserializeObject(json); + + Assert.IsNotNull(feature); + Assert.IsNotNull(feature.Properties); + Assert.IsEmpty(feature.Properties); + + Assert.AreEqual(GeoJSONObjectType.Polygon, feature.Geometry.Type); + } + [Test] public void Can_Serialize_LineString_Feature() { diff --git a/src/GeoJSON.Net.Tests/Feature/FeatureTests_Can_Deserialize_Feature_Without_Props.json b/src/GeoJSON.Net.Tests/Feature/FeatureTests_Can_Deserialize_Feature_Without_Props.json new file mode 100644 index 0000000..5c798b6 --- /dev/null +++ b/src/GeoJSON.Net.Tests/Feature/FeatureTests_Can_Deserialize_Feature_Without_Props.json @@ -0,0 +1,14 @@ +{ + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ 4.8892593383789062, 52.370725881211314 ], + [ 4.8952674865722656, 52.3711451105601 ], + [ 4.8920917510986328, 52.369310952782627 ], + [ 4.8892593383789062, 52.370725881211314 ] + ] + ] + } +} \ No newline at end of file diff --git a/src/GeoJSON.Net/Feature/Feature.cs b/src/GeoJSON.Net/Feature/Feature.cs index 5624cbc..3ced99e 100644 --- a/src/GeoJSON.Net/Feature/Feature.cs +++ b/src/GeoJSON.Net/Feature/Feature.cs @@ -39,7 +39,7 @@ public Feature(TGeometry geometry, TProps properties, string id = null) [JsonConverter(typeof(GeometryConverter))] public TGeometry Geometry { get; } - [JsonProperty(PropertyName = "properties", Required = Required.AllowNull)] + [JsonProperty(PropertyName = "properties", Required = Required.Default)] public TProps Properties { get; } ///