Convert the object to its JSON representation.

@param int $options

@return string
972655
public function toJson($options = 0)
    {
        return [
            'id' => $this->job->getId(),
            'data' => $this->job->getData(),
            'stats' => $this->stats,
        ];
    }
553761
public function getData($uri, $options = [])
    {
        return json_decode($this->request('GET', $uri, $options)->getBody()->getContents());
    }
1216794
public function serialize(Options $options)
    {
        return [
            'id' => $options->getId(),
            'data' => $options->getOptions(),
            'user' => $this->userSerializer->serialize($options->getUser()),
        ];
    }
1097361
public static function fromJson($json, int $options = 0)
    {
        $result = json_decode($json, true, 512, $options);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new JsonDecodeException(json_last_error_msg());
        }

        return new static(\is_array($result) ? $result : []);
    }
851946
public function getData(Options $options = null)
    {
        if ($options === null) {
            // Take store global/default options
            $options = $this->store->getOptions();
            // By default formatters are disabled in JSON
            $options->getHydrationOptions()->disableFormatters();
        }

        $data = $this->store->getData($options);
        $d = [
            'success' => true,
            'total' => $data->getTotalRows(),
            'start' => $data->getSource()->getOptions()->getOffset(),
            'limit' => $data->getSource()->getOptions()->getLimit(),
            'data' => $data->toArray()
        ];

        if ($this->options['debug']) {
            $source = $data->getSource();
            if ($source instanceof QueryableSourceInterface) {
                $d['query'] = $source->getQueryString();
            }
        }

        return Encoder::encode($d);
    }
13948
public static function export($options)
    {
        $defaults = [
            'collector' => null,
            'base_path' => getcwd()
        ];
        $options += $defaults;

        $collector = $options['collector'];

        $export = [];

        $base = $options['base_path'] ? rtrim($options['base_path'], DS) . DS : '';

        foreach ($collector->export() as $file => $coverage) {
            $path = $base . $file;
            $export[$path] = static::_export($path, $collector->parse($file), $coverage);
        }

        return json_encode($export);
    }
846513
protected function getUrl(array $options): string
    {
        $urlOptions = [];
        $this->setOriginAndDestinationOption($urlOptions, $options);
        $this->setViaOption($urlOptions, $options);
        $this->setDateOption($urlOptions, $options);

        $urlOptions = array_merge($urlOptions, $options);

        return sprintf('trip?%s&format=json', http_build_query($urlOptions));
    }
850463
public function apiSerialize($object, $options = [])
    {
        if (!empty($object)) {
            return $this->serializerProvider->serialize($object, $options);
        }

        return $object;
    }
82388
public static function encode($value, $options = null)
    {
        if ($options === null) {
            $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT;
        }

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

        static::handleJsonError(json_last_error());

        return $json;
    }
292950
public static function toJson($data, $options = array())
    {
        // Merge options with defaults
        $defaults = array('hide' => array('password'));
        $options = array_merge($defaults, $options);

        // Convert the data to an array, if possible..
        if (!is_array($data)) {
            $data = Arr::convert($data);
        }

        foreach ($data as $k => $v) {
            $data[$k] = Arr::convert($v);
        }

        // Remove the parts we don't want...
        if (isset($options['hide']) and is_array($data)) {
            $data = Arr::removeKeys($data, $options['hide']);
        }

        return json_encode($data);
    }
297425
protected function encodeOptions(array $options) {
        if (0 === count($options)) {
            return "{}";
        }
        ksort($options);
        $output = json_encode($options, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
        return str_replace("\n", "\n        ", $output);
    }
485357
public function getDataAsJsonString($option = 0, $depth = 512): string
    {
        $data = $this->get();

        if (\is_object($data) || \is_array($data)) {
            $data = \json_encode($data, $option, $depth);
        } else {
            $data = \json_encode([$data], $option, $depth);
        }

        return \json_encode($data, $option, $depth);
    }
987252
public function getObject(array $options = array())
    {
        $content = $this->getContent();

        if (is_null($content)) {
            return (object)$content;
        }

        return json_decode($this->content, false);
    }
706793
public function toJson($options = 0, $includeMetaData = false, $nestedInclude = true, $callback = null)
	{
		$data = $this->toArray($includeMetaData, $nestedInclude, $callback);
		return json_encode($data, $options);
	}
1112538
public static function encode(
        $value,
        int $options = 0,
        int $depth = 512,
        string $context = ''
    ): string {
        // Clear json_last_error()
        json_encode(null);

        $json = json_encode($value, $options, $depth);

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new JsonError(
                sprintf(
                    'Unable to encode data to JSON: %s. %s',
                    json_last_error_msg(),
                    $context
                )
            );
        }

        return $json;
    }
746108
private static function toJson(&$var, array $options, int $level = 0)
    {
        if (\is_bool($var) || null === $var || \is_int($var)) {
            return $var;

        }

        if (\is_float($var)) {
            return \is_finite($var)
                ? (\strpos($tmp = \json_encode($var), '.') ? $var : ['number' => "$tmp.0"])
                : ['type' => (string) $var];

        }

        if (\is_string($var)) {
            return self::encodeString($var, $options[self::TRUNCATE]);
        }

        if (\is_array($var)) {
            static $marker;
            if ($marker === null) {
                $marker = \uniqid("\x00", true);
            }
            if (isset($var[$marker]) || $level >= $options[self::DEPTH]) {
                return [null];
            }
            $res = [];
            $var[$marker] = true;
            foreach ($var as $k => & $v) {
                if ($k !== $marker) {
                    $hide = \is_string($k) && isset($options[self::KEYS_TO_HIDE][\strtolower($k)]);
                    $k = \is_int($k) || \preg_match('#^\w{1,50}\z#', $k) ? $k : '"' . self::encodeString($k,
                            $options[self::TRUNCATE]) . '"';
                    $res[] = [$k, $hide ? self::HIDDEN_VALUE : self::toJson($v, $options, $level + 1)];
                }
            }
            unset($var[$marker]);

            return $res;
        }

        if (\is_object($var)) {
            $obj = &self::$liveStorage[\spl_object_hash($var)];
            if ($obj && $obj['level'] <= $level) {
                return ['object' => $obj['id']];
            }

            $editorInfo = null;
            if ($options[self::LOCATION] & self::LOCATION_CLASS) {
                $rc = $var instanceof \Closure ? new \ReflectionFunction($var) : new \ReflectionClass($var);
                $editor = $rc->getFileName() ? Helpers::editorUri($rc->getFileName(), $rc->getStartLine()) : null;
                $editorInfo = $editor ? [
                    'file' => $rc->getFileName(), 'line' => $rc->getStartLine(), 'url' => $editor,
                ] : null;
            }
            static $counter = 1;
            $obj = $obj ?: [
                'id' => self::$livePrefix . '0' . $counter++, // differentiate from resources
                'name' => Helpers::getClass($var),
                'editor' => $editorInfo,
                'level' => $level,
                'object' => $var,
            ];

            if ($level < $options[self::DEPTH] || !$options[self::DEPTH]) {
                $obj['level'] = $level;
                $obj['items'] = [];

                foreach (self::exportObject($var, $options[self::OBJECT_EXPORTERS],
                    $options[self::DEBUGINFO]) as $k => $v) {
                    $vis = 0;
                    if (isset($k[0]) && $k[0] === "\x00") {
                        $vis = $k[1] === '*' ? 1 : 2;
                        $k = \substr($k, \strrpos($k, "\x00") + 1);
                    }
                    $hide = \is_string($k) && isset($options[self::KEYS_TO_HIDE][\strtolower($k)]);
                    $k = \is_int($k) || \preg_match('#^\w{1,50}\z#', $k) ? $k : '"' . self::encodeString($k,
                            $options[self::TRUNCATE]) . '"';
                    $obj['items'][] = [$k, $hide ? self::HIDDEN_VALUE : self::toJson($v, $options, $level + 1), $vis];
                }
            }

            return ['object' => $obj['id']];
        }

        if (\is_resource($var)) {
            $obj = &self::$liveStorage[(string) $var];
            if (!$obj) {
                $type = \get_resource_type($var);
                $obj = ['id' => self::$livePrefix . (int) $var, 'name' => $type . ' resource'];
                if (isset(self::$resources[$type])) {
                    foreach ((self::$resources[$type])($var) as $k => $v) {
                        $obj['items'][] = [$k, self::toJson($v, $options, $level + 1)];
                    }
                }
            }

            return ['resource' => $obj['id']];
        }

        return ['type' => 'unknown type'];
    }
489054
public static final function jsonDecode($data, array $options = null): array
    {
        $encoder = new JsonEncoder($options);

        return [$encoder->decode($data), $encoder->hasError()
            ? new EncoderException('JSON Error: '. $encoder->getError()) : null];
    }