Skip to content

Commit

Permalink
deserialization: avoid null values
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiedentop committed Feb 29, 2024
1 parent 5068c95 commit a788b56
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/src/geojson.dart
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,9 @@ class Feature<T extends GeometryObject> extends GeoJSONObject {

@override
Map<String, dynamic> toJson() => super.serialize({
'id': id,
'geometry': geometry!.toJson(),
'properties': properties,
if (id != null) 'id': id,
if (geometry != null) 'geometry': geometry!.toJson(),
if (geometry != null) 'properties': properties,
...fields,
});

Expand Down Expand Up @@ -721,7 +721,7 @@ class FeatureCollection<T extends GeometryObject> extends GeoJSONObject {
@override
Map<String, dynamic> toJson() => super.serialize(<String, dynamic>{
'features': features.map((e) => e.toJson()).toList(),
'bbox': bbox?.toJson(),
if (bbox != null) 'bbox': bbox!.toJson(),
});

@override
Expand Down

0 comments on commit a788b56

Please sign in to comment.