public function jsonSerialize()
    {
        $result = new \stdClass();
        $schema = static::schema();
        foreach ($schema->getProperties()->getDataKeyMap() as $propertyName => $dataName) {
            $value = $this->$propertyName;
            if ((null !== $value) || array_key_exists($propertyName, $this->__arrayOfData)) {
                $result->$dataName = $value;
            }
        }
        foreach ($schema->getNestedPropertyNames() as $name) {
            /** @var ObjectItem $nested */
            $nested = $this->$name;
            if (null !== $nested) {
                foreach ((array)$nested->jsonSerialize() as $key => $value) {
                    $result->$key = $value;
                }
            }
        }

        return $result;
    }