Here's a rather simple patch that allows spatial data to be json-serialized through native PHP toolset. I am far from being 100% sure this patch covers all use cases, but it does mine (Symfony FOS rest bundle with a JSON content type).
Coverage decreased (-17.9%) to 80.119% when pulling 7013441ca73cd1324bb639ea86b82f50287344a2 on bucefal91:140-json-serializable into 58ea5fae1c1b450ee08d7dac25cd9e8f5e6fdebd on creof:master.
This request #209 which implements JsonSerializable. You could have a look at this fork. Deployed on packagist, a new package is now available for PHP7.2+
Here's a rather simple patch that allows spatial data to be json-serialized through native PHP toolset. I am far from being 100% sure this patch covers all use cases, but it does mine (Symfony FOS rest bundle with a JSON content type).