src/Mordilion/Configurable/Configuration/Writer/Json.php
private function encode($configuration): string
    {
        if ($configuration instanceof ConfigurationInterface) {
            $configuration = $configuration->toArray();
        }

        if (!is_array($configuration)) {
            throw new \InvalidArgumentException('The provided configuration is not an array or an instance of ConfigurationInterface.');
        }

        $result = json_encode($configuration, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);

        if ($result !== false) {
            return $result;
        }

        throw new \RuntimeException(json_last_error_msg());
    }
private function encode($configuration): string
    {
        if ($configuration instanceof ConfigurationInterface) {
            $configuration = $configuration->toArray();
        }

        if (!is_array($configuration)) {
            throw new \InvalidArgumentException('The provided configuration is not an array or an instance of ConfigurationInterface.');
        }

        $result = json_encode($configuration, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);

        if ($result !== false) {
            return $result;
        }

        throw new \RuntimeException(json_last_error_msg());
    }
Encodes the provided $configuration into a JSON string.

@param array|ConfigurationInterface $configuration

@throws \InvalidArgumentException if the provided configuration is not an array or an instance of ConfigurationInterface
@throws \RuntimeException if the decoding throwed some errors

@return string