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()
9292
9393 protected $ __validateOnSet = true ; // todo skip validation during import
9494
95+ /**
96+ * @return \stdClass
97+ */
9598 public function jsonSerialize ()
9699 {
97100 $ result = new \stdClass ();
98101 $ schema = static ::schema ();
102+ $ classname = $ schema ->getObjectItemClass ();
103+ $ classReference = (class_exists ($ classname )) ? new $ classname () : new \stdClass ();
99104 $ properties = $ schema ->getProperties ();
100105 if (null !== $ properties ) {
101106 foreach ($ properties ->getDataKeyMap () as $ propertyName => $ dataName ) {
102107 $ 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+ ) {
104122 $ result ->$ dataName = $ value ;
105123 }
106124 }
@@ -154,4 +172,4 @@ public function validate()
154172 {
155173 static ::schema ()->out ($ this );
156174 }
157- }
175+ }
You can’t perform that action at this time.
0 commit comments