Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/GeoJSON.Net.Tests/Feature/FeatureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Net.Feature.Feature>(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()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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 ]
]
]
}
}
2 changes: 1 addition & 1 deletion src/GeoJSON.Net/Feature/Feature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

/// <summary>
Expand Down