public function json($options = 0, $withDeferred = false)
    {
        $attributes = $this->attributes;
        if ($withDeferred) {
            foreach ($this->deferred as $attribute => $collection) {
                if (empty($collection)) {
                    continue; // Leave orriginal array with __deferred key
                }

                $attributes[$attribute] = [];
                foreach ($collection as $value) {
                    if (! empty($value->deferred)) {
                        $value->attributes = array_merge($value->attributes, $value->deferred);
                    }

                    if (is_a($value, 'Picqer\Financials\Exact\Model')) {
                        array_push($attributes[$attribute], $value->attributes);
                    } else {
                        array_push($attributes[$attribute], $value);
                    }
                }
            }
        }

        return json_encode($attributes, $options);
    }