Decodes the JSON

@param   string  value

@return  mixed
509279
public static function type_json_decode($var, $settings)
	{
		$assoc = false;
		if (array_key_exists('json_assoc', $settings))
		{
			$assoc = (bool)$settings['json_assoc'];
		}
		return json_decode($var, $assoc);
	}
942889
static function toJSON($value, $format = true)
    {
        if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
            $f = JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE;
            if ($format) $f = $f|JSON_PRETTY_PRINT;
            return json_encode($value, $f);
        }else{
            return F::special_unicode_to_utf8(json_encode($value));
        }
    }
1317452
public static function decodeForMaria($value)
    {
        return is_string($value) && strpos($value, self::DATA_URI_PREFIX) === 0
            ? file_get_contents($value)
            : $value;
    }
607690
public static function decodeLabelSafe($value)
    {
        if (empty($value)) {
            return $value;
        }
        $raw = urldecode($value);
        $value = htmlspecialchars_decode($raw, ENT_QUOTES);

        // ENT_IGNORE so that if utf8 string has some errors, we simply discard invalid code unit sequences
        $style = ENT_QUOTES | ENT_IGNORE;

        // See changes in 5.4: http://nikic.github.com/2012/01/28/htmlspecialchars-improvements-in-PHP-5-4.html
        // Note: at some point we should change ENT_IGNORE to ENT_SUBSTITUTE
        $value = htmlspecialchars($value, $style, 'UTF-8');

        return $value;
    }
625882
public function filter($value)
    {
        if (!is_string($value)) {
            return $value;
        }

        return json_decode($value, $this->assoc, $this->depth, $this->options);
    }
953766
protected function handleJsonType($value)
    {
        if (($repo = $this->getRepository())) {
            if (($cast = array_get($repo->getCasts(), $this->name)) && in_array($cast, ['array', 'json'], true)) {
                $value = json_encode($value);
            }
        }

        return $value;
    }
928980
protected function decodeQuorum($value)
    {
        if (isset(self::$decode[$value])) {
            return self::$decode[$value];
        }

        return $value;
    }
852862
protected function serialize($value)
    {
        $jsonOptions = JSON_PRETTY_PRINT;
        if (defined('JSON_UNESCAPED_SLASHES')) {
            $jsonOptions |= JSON_UNESCAPED_SLASHES;
        }
        $type = gettype($value);
        $result = null;
        switch ($type) {
            case 'array':
                $result = json_encode($value, $jsonOptions);
                break;

            case 'boolean':
                $result = $value ? 'true' : 'false';
                break;

            case 'NULL':
                $result = 'null';
                break;

            case 'integer':
            case 'double':
                $result = (string)$value;
                break;

            case 'string':
                $enquote = false;
                switch ($value) {
                    case 'true':
                    case 'false':
                    case 'null':
                        $enquote = true;
                        break;

                    default:
                        if (preg_match('/^-?\d+(\.\d*)?$/', $value)) {
                            $enquote = true;
                        }
                        break;
                }
                $result = $enquote ? "\"$value\"" : $value;
                break;
        }
        if (!isset($result)) {
            throw new Exception("Unable to represent variable of type '$type'");
        }

        return $result;
    }
441900
protected function parseAsJson($value)
    {
        if (is_string($value)) {
            $value = json_decode($value, true);
            $error = json_last_error();
            if ($error !== JSON_ERROR_NONE) {
                switch ($error) {
                    case JSON_ERROR_DEPTH:
                        $message = 'Maximum stack depth exceeded';
                        break;
                    case JSON_ERROR_STATE_MISMATCH:
                        $message = 'Underflow or the modes mismatch';
                        break;
                    case JSON_ERROR_CTRL_CHAR:
                        $message = 'Unexpected control character found';
                        break;
                    case JSON_ERROR_SYNTAX:
                        $message = 'Syntax error, malformed JSON';
                        break;
                    case JSON_ERROR_UTF8:
                        $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
                        break;
                    default:
                        $message = 'Unknown error';
                        break;
                }

                throw new InvalidArgumentException(sprintf(
                    'Value "%s" could not be parsed as JSON: "%s"',
                    is_object($value) ? get_class($value) : gettype($value),
                    $message
                ));
            }
        }

        return $value;
    }
499450
final protected function decode(string $value): string
    {
        $parts = \imap_mime_header_decode($value);
        if (!\is_array($parts)) {
            return $value;
        }

        $decoded = '';
        foreach ($parts as $part) {
            $text = $part->text;
            if ('default' !== $part->charset) {
                $text = Transcoder::decode($text, $part->charset);
            }
            // RFC2231
            if (1 === \preg_match('/^(?<encoding>[^\']+)\'[^\']*?\'(?<urltext>.+)$/', $text, $matches)) {
                $hasInvalidChars = 1 === \preg_match('#[^%a-zA-Z0-9\-_\.\+]#', $matches['urltext']);
                $hasEscapedChars = 1 === \preg_match('#%[a-zA-Z0-9]{2}#', $matches['urltext']);
                if (!$hasInvalidChars && $hasEscapedChars) {
                    $text = Transcoder::decode(\urldecode($matches['urltext']), $matches['encoding']);
                }
            }

            $decoded .= $text;
        }

        return $decoded;
    }
871996
def _get_json(value):
    """"""
    if hasattr(value, 'replace'):
        value = value.replace('\n', ' ')
    try:
        return json.loads(value)
    except json.JSONDecodeError:
        # Escape double quotes.
        if hasattr(value, 'replace'):
            value = value.replace('"', '\\"')
        # try putting the value into a string
        return json.loads('"{}"'.format(value))
1282151
public function getValueAttribute($value) {
        if ($this->isJson($value)) {
            return json_decode($value);
        }
        if ($this->isSerialized($value)) {
            return unserialize($value);
        }
        return $value;
    }
368783
public function encodeValue($value)
    {
        if (is_bool($value)) {
            return (int) $value;
        }

        if ($value instanceof Enum) {
            return $value->name();
        }

        if ($value instanceof Stream) {
            return json_encode($value->__toString());
        }

        return json_encode($value);
    }
1219271
private function _jsonDecodeValues($key, $value) {

        $tmp_key   = json_decode($key);
        $tmp_value = json_decode($value);

        if($tmp_value && is_array($tmp_value) || is_object($tmp_value)) {
            array_walk_recursive($tmp_value, array($this, '_jsonConcatContents'));
            $value = $this->tmpJsonString;
        } else {
            $this->tmpJsonString .=  " " . $tmp_value . "\n";
        }

        if($tmp_key && is_array($tmp_key) || is_object($tmp_key)) {
            array_walk_recursive($tmp_key, array($this, '_jsonConcatContents'));
            $key = $this->tmpJsonString;
        } else {
            $this->tmpJsonString .=  " " . $tmp_key . "\n";
        }

        return array($key, $value);
    }
81817
public static function decode(string $value)
    {
        $stdObject = json_decode($value);
        // catch error if it occurs
        self::catchError();

        if (self::getError()) {
            return self::getError();
        }

        return $stdObject;
    }
392525
private function phpEncodeValue($value)
    {
        if (is_array($value)) {
            return $this->phpEncodeArray($value);
        }

        if (is_string($value)) {
            return json_encode($value);
        }

        return var_export($value, true);
    }
1250122
public static function htmlspecialchars_decode($value) {
		$value = str_replace('&gt;', '>', $value);
		$value = str_replace('&lt;', '<', $value);
		$value = str_replace('&quot;', '"', $value);
		$value = str_replace('&amp;', '&', $value);
		return $value;
	}