@@ -70,29 +70,24 @@ public static function create()
7070 return new static ;
7171 }
7272
73- protected $ __hasNativeProperties = true ;
7473 protected $ __validateOnSet = true ; // todo skip validation during import
7574
76- public function jsonSerialize () // todo process nested structures here
75+ public function jsonSerialize ()
7776 {
78- if ($ this ->__hasNativeProperties ) {
79- $ result = new \stdClass ();
80- $ properties = static ::schema ()->properties ;
81- foreach ($ properties ->toArray () as $ name => $ schema ) {
82- $ value = $ this ->$ name ;
83- if ((null !== $ value ) || array_key_exists ($ name , $ this ->__arrayOfData )) {
84- $ result ->$ name = $ value ;
85- }
77+ $ result = new \stdClass ();
78+ $ properties = static ::schema ()->properties ;
79+ foreach ($ properties ->toArray () as $ name => $ schema ) {
80+ $ value = $ this ->$ name ;
81+ if ((null !== $ value ) || array_key_exists ($ name , $ this ->__arrayOfData )) {
82+ $ result ->$ name = $ value ;
8683 }
87- foreach ( $ properties -> nestedPropertyNames as $ name ) {
88- /** @var ObjectItem $nested */
89- $ nested = $ this -> $ name ;
90- foreach (( array ) $ nested-> jsonSerialize () as $ key => $ value ) {
91- $ result -> $ key = $ value;
92- }
84+ }
85+ foreach ( $ properties -> nestedPropertyNames as $ name ) {
86+ /** @var ObjectItem $nested */
87+ $ nested = $ this -> $ name ;
88+ foreach (( array ) $ nested -> jsonSerialize () as $ key => $ value) {
89+ $ result -> $ key = $ value ;
9390 }
94- } else {
95- $ result = parent ::jsonSerialize ();
9691 }
9792
9893 return $ result ;
0 commit comments