public static function decode(string $json): self
    {
        if (!$document = self::fromString($json)) {
            throw new \InvalidArgumentException('Invalid JSON string.');
        }

        return $document;
    }