@param string $json

@throws DecodingException
767532
protected static function throwDecodingExceptionIfOccurred($json)
    {
        if (JSON_ERROR_NONE === json_last_error()) {
            return;
        }

        $decodingException = new DecodingException(
            sprintf('JSON decoding failed: %s', json_last_error_msg()),
            json_last_error()
        );

        $decodingException->setDecodingData($json);

        throw $decodingException;
    }
326961
public static function convertFromJSON($json)
    {
        $object = json_decode($json, true);
        $bencode = self::encode($object);

        return $bencode;
    }
1244844
public static function parseJSON($json) 
    {
        if (function_exists('json_decode')) {
            $return = json_decode(trim($json), true);
            // json_decode and UTF8 issues
            if (isset($return)) {
                return $return;
            }
        }
        include_once 'Zend/Json/Decoder.php';
        return Zend_Json_Decoder::decode($json);
    }
174214
public function transformJsonResponse($json)
    {
        // In a REST-API call, the first five chars are )]}'\n
        // to decode it, we have to strip it
        // See https://review.typo3.org/Documentation/rest-api.html#output
        if (substr($json, 0, 4) === ')]}\'') {
            $json = substr($json, 5);
        }

        return json_decode($json, true);
    }
1283967
public static function json_decode($json, $assoc=false) {
		//replace single quoted values
		$json = preg_replace_callback('/:\s*\'(([^\']|\\\\\')*)\'\s*([},])/', function ($m) {
			return ':' . json_encode(stripslashes($m[1])) . $m[3];
		}, $json);

		//replace single quoted keys
		$json = preg_replace_callback('/\'(([^\']|\\\\\')*)\'\s*:/', function($m){
			return json_encode(stripslashes($m[1])) . ':';
		}, $json);
		//remove any line breaks in the code
		$json = str_replace(array("\n","\r"),"",$json);

		//replace non-quoted keys with double quoted keys
		$json = preg_replace('#(?<pre>\{|\[|,)\s*(?<key>(?:\w|_)+)\s*:#im', '$1"$2":', $json);

		//remove trailing comma
		$json = preg_replace('/,\s*\}/','}',$json);

		$return = json_decode($json, $assoc);
		$error = json_last_error_msg();
		return $return;
	}
1256974
public static function jsonDecode($json, $assoc = false) {
        if (!$json) {
            throw new \Exception("Can't json_decode empty string [{$json}]");
        }

        $data = json_decode($json, $assoc);

        if ($data === null) {
            throw new \Exception("Failed to json_decode [{$json}]");
        }

        return $data;
    }
932392
public function parseJson($json)
    {
        $this->id = $json['id'];
        $this->name = $json['name'];
        $this->links = $json['links'];

        if (isset($json['xmpp_jid'])) {
            $this->xmppJid = $json['xmpp_jid'];
            //Statistics need to be implemented
            $this->created = new \DateTime($json['created']);
            $this->archived = $json['is_archived'];
            $this->privacy = $json['privacy'];
            $this->guestAccessible = $json['is_guest_accessible'];
            $this->topic = $json['topic'];
            $this->participants = array();
            foreach ($json['participants'] as $participant) {
                $this->participants[] = new User($participant);
            }
            $this->owner = new User($json['owner']);
            $this->guestAccessUrl = $json['guest_access_url'];
        }
    }
1048197
public static function fromJson(string $json) : self
    {
        if (empty($json)) {
            throw new JsonParseException('An empty string is not a valid JSON value', JSON_ERROR_SYNTAX, null, $json);
        }
        $parsed = json_decode($json, true);

        $lastError = json_last_error();

        if (\JSON_ERROR_NONE !== $lastError) {
            throw JsonParseException::fromJsonError($lastError, $json);
        }

        return static::decompile($parsed);
    }
1185232
public function parseJson($json)
    {
        $this->mentionName = $json['mention_name'];
        $this->id = $json['id'];
        $this->name = $json['name'];
        if (isset($json['links'])) {
            $this->links = $json['links'];
        }
        if(isset($json['xmpp_jid'])) {
            $this->xmppJid = $json['xmpp_jid'];
            $this->deleted = $json['is_deleted'];
            $this->lastActive = $json['last_active'];
            $this->title = $json['title'];
            $this->created = new \Datetime($json['created']);
            $this->groupAdmin = $json['is_group_admin'];
            $this->timezone = $json['timezone'];
            $this->guest = $json['is_guest'];
            $this->email = $json['email'];
            $this->photoUrl = $json['photo_url'];
        }
    }
1085673
public function jsonDecode($json, $assoc = false)
    {
        // if json_decode exists use that
        if (extension_loaded('json') && function_exists('json_decode')) {
            $decodedValue = json_decode($json, $assoc);
            if (!empty($decodedValue)) {
                return $decodedValue;
            }
        }

        try {
            return \Zend\Json\Decoder::decode(
                $json,
                $assoc
                    ? \Zend\Json\Json::TYPE_ARRAY
                    : \Zend\Json\Json::TYPE_OBJECT
            );
        } catch (Exception $exception) {
            // if a string is no valid json this call will throw Zend\Json\Exception\RuntimeException
            return null;
        }
    }
1178951
protected function jsonDecode($json)
    {
        $content = json_decode((string) $json, true);
        $this->handleJsonError(json_last_error());
        
        return $content;
    }
705995
public static function decode($json, $assoc = false)
    {
        if ($json instanceof Response) {
            return json_decode($json->getContent(), $assoc);
        }

        return json_decode($json, $assoc);
    }
1228828
private function validateSyntax($json)
    {
        $parser = new JsonParser();
        $result = $parser->lint($json);
        if ($result === null) {
            return;
        }

        throw new ParsingException(sprintf("The configuration file \"%s\" does not contain valid JSON.\n%s", $this->configurationFile, $result->getMessage()), $result->getDetails());
    }
66723
public function decode($json)
    {
        $decoded = json_decode($json, true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            return null;
        }

        return $decoded;
    }
1016645
protected void parse(String json) {
        logger.entering(json);

        try {
            Gson gson = new Gson();
            BaseLog baseLog = gson.fromJson(json, this.getClass());
            this.msg = baseLog.msg;
            this.screen = baseLog.screen;
            this.location = baseLog.location;
            this.href = baseLog.href;
        } catch (JsonSyntaxException e) {
            // If not JSON string then treat this as an message
            this.msg = json;
        }

        logger.exiting();
    }
345328
protected static function decode($json, array $context)
    {
        $result = json_decode(
            $json,
            $context['json_decode_assoc'],
            $context['json_decode_depth'],
            $context['json_decode_options']
        );

        if (null === $result) {
            static::throwDecodingExceptionIfOccurred($json);
        }

        return $result;
    }
618781
public function setJson($json)
    {
        global $CFG, $PDOX;

        $q = $PDOX->queryDie("UPDATE {$CFG->dbprefix}{$this->TABLE_NAME}
                SET json = :SET WHERE $this->PRIMARY_KEY = :PK",
            array(":SET" => $json, ":PK" => $this->id)
        );
    }