Supported Versions: PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL json >= 1.2.0
Returns the JSON representation of a value
<?php json_encode(mixed $value, int $flags = 0, int $depth = 512): string|false
<?php             }



            if (is_array($value)) {

                $value = json_encode($value);

            }



            $sourceOfConfigValue = '';
<?php         if (true !== $validation = $validator($values)) {

            throw new \RuntimeException(sprintf(

                '%s is an invalid value'.($validation ? ' ('.$validation.')' : ''),

                json_encode($values)

            ));

        }
<?php             if (is_array($value)) {

                $value = array_map(function ($val) {

                    return is_array($val) ? json_encode($val) : $val;

                }, $value);



                $value = '['.implode(', ', $value).']';
<?php                 return 1;

            }

        } else {

            if (json_encode($options) === '{"require":{}}') {

                throw new \RuntimeException('You have to run this command in interactive mode, or specify at least some data using --name, --require, etc.');

            }
<?php                     'http' => array(

                        'method' => 'POST',

                        'header' => array('Content-Type: application/json'),

                        'content' => json_encode($postData),

                        'timeout' => 6,

                    ),

                );
<?php     public static function encode($data, $options = 448)

    {

        $json = json_encode($data, $options);

        if (false === $json) {

            self::throwEncodeError(json_last_error());

        }
<?php     private function createObject(array $config, $class)

    {

        if (!isset($config['name'])) {

            throw new \UnexpectedValueException('Unknown package has no name defined ('.json_encode($config).').');

        }

        if (!isset($config['version'])) {

            throw new \UnexpectedValueException('Package '.$config['name'].' has no version defined.');
<?php                 throw new \UnexpectedValueException(sprintf(

                    "Package %s's source key should be specified as {\"type\": ..., \"url\": ..., \"reference\": ...},\n%s given.",

                    $config['name'],

                    json_encode($config['source'])

                ));

            }

            $package->setSourceType($config['source']['type']);
<?php                     "Package %s's dist key should be specified as ".

                    "{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",

                    $config['name'],

                    json_encode($config['dist'])

                ));

            }

            $package->setDistType($config['dist']['type']);
<?php                         if ($licenseValidator->validate(trim($licenseToValidate))) {

                            $this->warnings[] = sprintf(

                                'License %s must not contain extra spaces, make sure to trim it.',

                                json_encode($license)

                            );

                        } else {

                            $this->warnings[] = sprintf(
<?php                             $this->warnings[] = sprintf(

                                'License %s is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.' . PHP_EOL .

                                'If the software is closed-source, you may use "proprietary" as license.',

                                json_encode($license)

                            );

                        }

                    }
<?php             } else {

                foreach ($this->config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {

                    if (!is_string($targetBranch)) {

                        $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.json_encode($targetBranch).') must be a string, "'.gettype($targetBranch).'" received.';

                        unset($this->config['extra']['branch-alias'][$sourceBranch]);



                        continue;
<?php         if (!isset($packageConfig['extra']['branch-alias'][$version])

            || strpos(json_encode($packageConfig), '"self.version"')

        ) {

            $branch = Preg::replace('{^dev-}', '', $version);

            $length = PHP_INT_MAX;
<?php             return $packageInstances;

        } catch (\Exception $e) {

            throw new \RuntimeException('Could not load packages '.(isset($packages[0]['name']) ? $packages[0]['name'] : json_encode($packages)).' in '.$this->getRepoName().($source ? ' from '.$source : '').': ['.get_class($e).'] '.$e->getMessage(), 0, $e);

        }

    }
<?php             try {

                $package = $loader->load($package);

            } catch (\Exception $e) {

                throw new InvalidRepositoryException('A repository of type "package" contains an invalid package definition: '.$e->getMessage()."\n\nInvalid package definition:\n".json_encode($package));

            }



            $this->addPackage($package);