Enforce the default JSON settings.

@param array $json

@return array
329339
private function setJsonDefaults(array $json)
    {
        $config = $this->app['config'];
        $pathResolver = $this->app['path_resolver'];

        $rootPath = $pathResolver->resolve('root');
        $extensionsPath = $pathResolver->resolve('extensions');
        $webPath = $pathResolver->resolve('web');
        $pathToRoot = Path::makeRelative($rootPath, $extensionsPath);
        $pathToWeb = Path::makeRelative($webPath, $extensionsPath);
        $pathToListeners = Path::makeRelative(__DIR__ . '/EventListener', $extensionsPath);
        /** @deprecated Handle BC on 'stability' key until 4.0 */
        $minimumStability = $config->get('general/extensions/stability') ?: $config->get('general/extensions/composer/minimum-stability', 'stable');

        $config = $config->get('general/extensions/composer/config', []) + [
            'discard-changes'   => true,
            'preferred-install' => 'dist',
        ];

        // Enforce standard settings
        $defaults = [
            'name'         => 'bolt/extensions',
            'description'  => 'Bolt extension installation interface',
            'license'      => 'MIT',
            'repositories' => [
                'packagist' => false,
                'bolt'      => [
                    'type' => 'composer',
                    'url'  => $this->app['extend.site'] . 'satis/',
                ],
            ],
            'minimum-stability' => $minimumStability,
            'prefer-stable'     => true,
            'config'            => $config,
            'provide'           => [
                'bolt/bolt' => Bolt\Version::forComposer(),
            ],
            'extra' => [
                'bolt-web-path'  => $pathToWeb,
                'bolt-root-path' => $pathToRoot,
            ],
            'autoload' => [
                'psr-4' => [
                    'Bolt\\Composer\\EventListener\\' => $pathToListeners,
                ],
            ],
            'scripts' => [
                'post-autoload-dump'   => 'Bolt\\Composer\\EventListener\\PackageEventListener::dump',
                'post-package-install' => 'Bolt\\Composer\\EventListener\\PackageEventListener::handle',
                'post-package-update'  => 'Bolt\\Composer\\EventListener\\PackageEventListener::handle',
            ],
        ];
        $json = Arr::replaceRecursive($json, $defaults);
        ksort($json);

        return $json;
    }
1237751
protected function json($key = null, $default = null)
    {
        if (null === $key) {
            return Request::json()->all();
        } else {
            return Request::json($key, $default);
        }
    }
77301
public static function create(array $json)
    {
        $createMessageResponse = new CreateMessageResponse();
        $createMessageResponse->setStatusCode($json['status_code']);
        $createMessageResponse->setStatusMessage($json['status_message']);

        // If a 'response' is provided
        if (array_key_exists('response', $json) && isset($json['response'])) {
            $createMessageResponseResponse = new CreateMessageResponseResponse();

            // If 'Messages' are provided
            if (array_key_exists('Messages', $json['response'])) {
                $createMessageResponseResponse->setMessages($json['response']['Messages']);
            }

            $createMessageResponse->setResponse($createMessageResponseResponse);
        }

        return $createMessageResponse;
    }
1336845
public static function jsonDeserialize( $json ) {
		return new self(
			$json['id'],
			$json['type'],
			$json['action'],
			$json['timestamp'],
			$json['user'],
			PageIdentifier::jsonDeserialize( $json['pageidentifier'] ),
			$json['comment'],
			$json['details']
		);
	}
743808
private function setJsonData(?string $json): self
    {
        $this->updatePropertyValue(
            JsonDataFieldInterface::PROP_JSON_DATA,
            $json
        );

        return $this;
    }
146423
public static function jsonToArray($json = false) {

        if ($json && Validate::isJson($json)) {

            $object = json_decode($json);
            return self::objectToArray($object);
        }

        return false;
    }
953623
public static function create(array $json)
    {
        $unregisterDeviceResponse = new UnregisterDeviceResponse();
        $unregisterDeviceResponse->setStatusCode($json['status_code']);
        $unregisterDeviceResponse->setStatusMessage($json['status_message']);

        return $unregisterDeviceResponse;
    }
12021
public static function json2arr($json)
    {
        $result = json_decode($json, true);
        if (empty($result)) {
            throw new InvalidResponseException('invalid response.', '0');
        }
        if (!empty($result['errcode'])) {
            throw new InvalidResponseException($result['errmsg'], $result['errcode'], $result);
        }
        return $result;
    }
543162
public static function fromJson($json)
    {
        $data = json_decode($json);

        // Recreate the object.
        $object = new static($data->username, $data->password, $data->url);
        $object->authToken = Token::fromJson(json_encode($data->authToken));
        $object->accessToken = Token::fromJson(json_encode($data->accessToken));
        $object->refreshToken = Token::fromJson(json_encode($data->refreshToken));
        $object->settings = Settings::fromJson(json_encode($data->settings));

        return $object;
    }
458510
public static function validateConditionsConfig(array $json) : void
    {
        foreach ($json as $condition) {
            if (!self::keysExist(['exec'], $condition) || empty($condition['exec'])) {
                throw new \RuntimeException('Config error: \'exec\' is required for conditions');
            }
            if (!empty($condition['args']) && !is_array($condition['args'])) {
                throw new \RuntimeException('Config error: invalid \'args\' configuration');
            }
        }
    }
203418
public static function convertImageJson($json): string
    {
        if (empty($json))
            return "";
        elseif (is_array($json) && !empty($json[0]['url']))
            return HOME . str_replace('\\', '/', $json[0]['url']);
        elseif (Check::isJson($json) && preg_match('/url/i', $json))
            return HOME . str_replace('\\', '/', json_decode($json, true)[0]['url']);

        return "";
    }
1084615
public static function validateJsonConfiguration(array $json) : void
    {
        foreach (HookUtil::getValidHooks() as $hook => $class) {
            if (isset($json[$hook])) {
                self::validateHookConfig($json[$hook]);
            }
        }
    }
369919
public static function json_base64_encode(array $arr, $json = true)
  {
    $res = [];
    foreach ( $arr as $i => $a ){
      if ( is_array($a) ){
        $res[$i] = self::json_base64_encode($a, false);
      }
      else if ( is_string($a) ){
        $res[$i] = base64_encode($a);
      }
      else{
        $res[$i] = $a;
      }
    }
    return $json ? json_encode($res) : $res;
  }
1318592
public static function create(array $json)
    {
        $deleteMessageResponse = new DeleteMessageResponse();
        $deleteMessageResponse->setStatusCode($json['status_code']);
        $deleteMessageResponse->setStatusMessage($json['status_message']);

        return $deleteMessageResponse;
    }
418418
protected static function getSentencesFromJSON($json)
    {
        $sentencesArray = json_decode($json, true);
        $sentences = "";

        foreach ($sentencesArray["sentences"] as $s) {
            $sentences .= isset($s["trans"]) ? $s["trans"] : '';
        }

        return $sentences;
    }
372552
public static function fromJson(string $json): self
    {
        $input = json_decode($json, true);
        $data = reset($input);
        $locale = key($input);
        
        return new self($locale, $data);
    }
731275
private function amendDynamicAttributesToJson(array &$json) {
        if (!is_null($this->package_version)) {
            $json['version'] = array();
            $json['version']['release'] = $this->package_version;
        }
        if (!is_null($this->package_name)) {
            $json['name'] = $this->package_name;
        }
    }