File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -92,15 +92,33 @@ public static function create()
92
92
93
93
protected $ __validateOnSet = true ; // todo skip validation during import
94
94
95
+ /**
96
+ * @return \stdClass
97
+ */
95
98
public function jsonSerialize ()
96
99
{
97
100
$ result = new \stdClass ();
98
101
$ schema = static ::schema ();
102
+ $ classname = $ schema ->getObjectItemClass ();
103
+ $ classReference = (class_exists ($ classname )) ? new $ classname () : new \stdClass ();
99
104
$ properties = $ schema ->getProperties ();
100
105
if (null !== $ properties ) {
101
106
foreach ($ properties ->getDataKeyMap () as $ propertyName => $ dataName ) {
102
107
$ value = $ this ->$ propertyName ;
103
- if ((null !== $ value ) || array_key_exists ($ propertyName , $ this ->__arrayOfData )) {
108
+ $ types = ($ schema ->getProperty ($ propertyName ) instanceof Schema)
109
+ ? $ schema ->getProperty ($ propertyName )->type
110
+ : null ;
111
+ if (
112
+ (
113
+ null !== $ value
114
+ ||
115
+ ($ value === null
116
+ && is_array ($ types )
117
+ && in_array ('null ' , $ types )
118
+ )
119
+ )
120
+ || array_key_exists ($ propertyName , $ this ->__arrayOfData )
121
+ ) {
104
122
$ result ->$ dataName = $ value ;
105
123
}
106
124
}
@@ -154,4 +172,4 @@ public function validate()
154
172
{
155
173
static ::schema ()->out ($ this );
156
174
}
157
- }
175
+ }
You can’t perform that action at this time.
0 commit comments