@@ -70,29 +70,24 @@ public static function create()
70
70
return new static ;
71
71
}
72
72
73
- protected $ __hasNativeProperties = true ;
74
73
protected $ __validateOnSet = true ; // todo skip validation during import
75
74
76
- public function jsonSerialize () // todo process nested structures here
75
+ public function jsonSerialize ()
77
76
{
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 ;
86
83
}
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 ;
93
90
}
94
- } else {
95
- $ result = parent ::jsonSerialize ();
96
91
}
97
92
98
93
return $ result ;
0 commit comments