From 538241f9b7be25a9e3fb5ba27ec35db5c4fc3855 Mon Sep 17 00:00:00 2001 From: Oleksandr Trotsenko Date: Sun, 19 Aug 2018 09:34:16 -0500 Subject: [PATCH] Introducing a general support for native JSON serialization. --- lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php b/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php index adc5a21e..9731e82d 100644 --- a/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php +++ b/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php @@ -32,7 +32,7 @@ * @author Derek J. Lambert * @license http://dlambert.mit-license.org MIT */ -abstract class AbstractGeometry implements GeometryInterface +abstract class AbstractGeometry implements GeometryInterface, \JsonSerializable { /** * @var int @@ -65,6 +65,13 @@ public function toJson() return json_encode($json); } + /** + * @return array + */ + public function jsonSerialize() { + return $this->toArray(); + } + /** * @return null|int */