From 2581e3347e09a7fdc7e0c23192614ef071b32b1a Mon Sep 17 00:00:00 2001 From: Evaldo Barbosa Date: Thu, 9 Feb 2017 12:11:15 -0300 Subject: [PATCH] solves json_encode problem. When an external thing (like a script or framework) not calling toJson method, json is returned empty --- lib/ArangoDBClient/Document.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ArangoDBClient/Document.php b/lib/ArangoDBClient/Document.php index b1dddc52..9194455f 100644 --- a/lib/ArangoDBClient/Document.php +++ b/lib/ArangoDBClient/Document.php @@ -19,7 +19,7 @@ * @package ArangoDBClient * @since 0.2 */ -class Document +class Document implements \JsonSerializable { /** * The document id (might be NULL for new documents) @@ -233,6 +233,11 @@ public function toJson(array $options = []) return json_encode($this->getAll($options)); } + public function jsonSerialize() + { + return $this->getAll([]); + } + /** * Returns the document as a serialized string *