Skip to content

Commit e17c68b

Browse files
Implement JsonSerializable on JsonModel
1 parent 12527a5 commit e17c68b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Models/JsonModel.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace NPR\One\Models;
44

5+
use JsonSerializable;
56

67
/**
78
* A thin abstraction to aide in transforming raw JSON into a model, yet allowing it to be re-encoded as JSON when
89
* stringified.
910
*
1011
* @package NPR\One\Models
1112
*/
12-
abstract class JsonModel
13+
abstract class JsonModel implements JsonSerializable
1314
{
1415
/** @var \stdClass - the original json used to construct this model, useful for debugging
1516
* @internal */
@@ -30,6 +31,14 @@ public function __construct($json)
3031
}
3132
}
3233

34+
/**
35+
* JSON Serialize the original JSON object
36+
*/
37+
public function jsonSerialize()
38+
{
39+
return $this->originalJsonObject;
40+
}
41+
3342
/**
3443
* Re-encodes the original JSON model as a string and returns it.
3544
*

0 commit comments

Comments
 (0)