From a788b56f35f510762d7616f7ad886b5c2bd79879 Mon Sep 17 00:00:00 2001 From: Jonas Siedentop Date: Thu, 29 Feb 2024 02:43:50 +0100 Subject: [PATCH] deserialization: avoid null values --- lib/src/geojson.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/geojson.dart b/lib/src/geojson.dart index c967e74..92c2bcc 100644 --- a/lib/src/geojson.dart +++ b/lib/src/geojson.dart @@ -683,9 +683,9 @@ class Feature extends GeoJSONObject { @override Map 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, }); @@ -721,7 +721,7 @@ class FeatureCollection extends GeoJSONObject { @override Map toJson() => super.serialize({ 'features': features.map((e) => e.toJson()).toList(), - 'bbox': bbox?.toJson(), + if (bbox != null) 'bbox': bbox!.toJson(), }); @override