Receives Data from Google Code Post-Commit Hook and returns JSON string.
@access		public
@return		string
@throws		RuntimeException if raw POST data is empty
@throws		RuntimeException if Key is invalid
2557
public function receiveData( Net_HTTP_Request_Receiver $request)
	{
		$data	= $request->getRawPostData();
		if( !$data )
			throw new RuntimeException( 'No raw POST data received' );
		$digest	= hash_hmac( "md5", $data, $this->authKey );
		$header	= array_pop( $request->getHeadersByName( $this->headerName ) );
		if( $digest !== $header->getValue() )
			throw new RuntimeException( 'Authentication failed' );
		return $data;
	}
1147553
function jsonSerialize()
    {
        $data = [
            'text' => $this->text
        ];

        if ($this->replyMarkup) {
            $data['reply_markup'] = $this->replyMarkup;
        }

        return $data;
    }
1298558
private function buildRequestData()
    {
        $strip_slashes_deep = function ($value) use (&$strip_slashes_deep) {
            if (is_object($value)) {
                $value = json_decode(json_encode($value), true);
            }

            if (is_array($value)) {
                return array_map($strip_slashes_deep, $value);
            }

            return sanitize_text_field(stripslashes($value));
        };

        $this->_GET = array_map($strip_slashes_deep, $_GET);
        $this->_POST = array_map($strip_slashes_deep, $_POST);
        $this->_COOKIE = array_map($strip_slashes_deep, $_COOKIE);
        $this->_FILES = array_map($strip_slashes_deep, $_FILES);
    }
215701
public function toResponseJSON()
    {
        // successful response
        $arr = array('jsonrpc' => self::JSON_RPC_VERSION);
        if ($this->result !== null) {
            $arr['result'] = $this->result;
            $arr['id'] = $this->id;
            return json_encode($arr);
        // error response
        } else {
            $arr['error'] = array('code' => $this->error_code, 'message' => $this->error_message);
            $arr['id'] = $this->id;
            return json_encode($arr);
        }
    }
175384
public function getDecodedJson():array
    {
        if (!($array = json_decode($this->json, true))) {
            throw new \RuntimeException("Unable to decode the response's JSON");
        }
        return json_decode($this->json, true);
    }
686836
public function getJSONString()
	{
		$json = '{'
				. '"@context":"' .			SocialRecord::JSONLD_CONTEXT . '",'
				. '"@type":"' .				SocialRecord::JSONLD_TYPE . '",'
				. '"type":"' .				$this->type . '",'
				. '"globalID":"' .			$this->globalID . '",'
				. '"platformGID":"' .		$this->platformGID . '",'
				. '"displayName":"' .		$this->displayName . '",'
				. '"profileLocation":"' .	$this->profileLocation . '",'
				. '"personalPublicKey":"' .	PublicKey::exportKey($this->personalPublicKey) . '",'
				. '"accountPublicKey":"' .	PublicKey::exportKey($this->accountPublicKey) . '",'
				. '"salt":"' .	 			$this->salt . '",'
				. '"datetime":"' .	 		$this->datetime . '",'
				. '"active":' . 			$this->active . ','
				. '"keyRevocationList":[';
				
		foreach($this->keyRevocationList as $krc)
		{
			$json .= $krc->getJSONString();
			if($krc !== end($this->keyRevocationList)) $json .= ',';
		}
		
		$json .= ']}';
		
		return $json;
	}
1353174
private function readStoredRoutineMetadata(): void
  {
    if (file_exists($this->phpStratumMetadataFilename))
    {
      $this->phpStratumMetadata = (array)json_decode(file_get_contents($this->phpStratumMetadataFilename), true);
      if (json_last_error()!=JSON_ERROR_NONE)
      {
        throw new RuntimeException("Error decoding JSON: '%s'.", json_last_error_msg());
      }
    }
  }
655049
protected function parseData()
    {
        if (strtoupper($this->getRequestMethod()) == 'GET') {
            $this->rawData = ($this->getQueryString()) ? rawurldecode($this->getQueryString()) : null;
        } else {
            $input = fopen('php://input', 'r');
            while ($data = fread($input, 1024)) {
                $this->rawData .= $data;
            }
        }

        // If the content-type is JSON
        if ($this->getQueryString() && stripos($this->getQueryString(), 'json') !== false) {
            $this->parsedData = json_decode($this->rawData, true);
        // Else, if the content-type is XML
        } elseif ($this->getContentType() && stripos($this->getContentType(), 'xml') !== false) {
            $matches = [];
            preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $this->rawData, $matches);

            foreach ($matches[0] as $match) {
                $strip = str_replace(
                    ['<![CDATA[', ']]>', '<', '>'],
                    ['', '', '&lt;', '&gt;'],
                    $match
                );
                $this->rawData = str_replace($match, $strip, $this->rawData);
            }

            $this->parsedData = json_decode(json_encode((array) simplexml_load_string($this->rawData)), true);
        // Else, default to a regular URL-encoded string
        } else {
            switch (strtoupper($this->getRequestMethod())) {
                case 'GET':
                    $this->parsedData = $this->get;
                    break;

                case 'POST':
                    $this->parsedData = $this->post;
                    break;
                default:
                    if ($this->getContentType() && strtolower($this->getContentType()) == 'application/x-www-form-urlencoded') {
                        parse_str($this->rawData, $this->parsedData);
                    }
            }
        }
        switch (strtoupper($this->getRequestMethod())) {
            case 'PUT':
                $this->put = $this->parsedData;
                break;

            case 'PATCH':
                $this->patch = $this->parsedData;
                break;

            case 'DELETE':
                $this->delete = $this->parsedData;
                break;
        }
    }
470158
public function toArrayAll()
    {
        $data = $this->toArray();

        foreach(self::$jsonable as $key){

            if(isset($data[$key]) && Utils::isJson($data[$key])){
                $data[$key] = json_decode($this->{$key});
            }
        }

        return $data;
    }
660298
public function getData()
    {
        if (empty($this->data)) {
            $rawData = file_get_contents('php://input');

            return json_decode($rawData, true);
        } else {
            return $this->data;
        }
    }
688054
public function json()
    {
        $data = json_decode((string) $this->body, true);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error());
        }

        return $data === null ? array() : $data;
    }
900194
public function getJsonBody() : array
    {
        $json = json_decode($this->getRawBody(), true);

        if ($json === null) {
            throw new RuntimeException('Body could not be decoded as JSON');
        }

        return $json;
    }
770278
public function getJson()
    {
        $dirty = $this->getDirty();
        if (count($dirty)) {
            $this->internal_original_value = $this->__toString();
        }

        return $this->internal_original_value;
    }
378666
public function getArrayResponse()
    {
        $json = [];
        $json['jsonrpc'] = '2.0';

        if ($this->errorCode) {

            $json['error'] = [];
            $json['error']['code'] = $this->errorCode;
            $json['error']['message'] = $this->errorMessage;

            if (!empty($this->errorData)) {
                $json['error']['data'] = $this->errorData;
            }

        } else {
            $json['result'] = $this->result;
        }

        $json['id'] = !empty($this->id) ? $this->id : null;

        return $json;
    }
17209
public function jsonSerialize()
    {
        $payload = self::getDefaultPayloadStructure();

        if ($this->alert instanceof Alert || is_string($this->alert)) {
            $payload[self::PAYLOAD_ROOT_KEY][self::PAYLOAD_ALERT_KEY] = $this->alert;
        }

        if (is_int($this->badge)) {
            $payload[self::PAYLOAD_ROOT_KEY][self::PAYLOAD_BADGE_KEY] = $this->badge;
        }

        if (is_string($this->sound)) {
            $payload[self::PAYLOAD_ROOT_KEY][self::PAYLOAD_SOUND_KEY] = $this->sound;
        }

        if (is_bool($this->contentAvailable)) {
            $payload[self::PAYLOAD_ROOT_KEY][self::PAYLOAD_CONTENT_AVAILABLE_KEY] = (int)$this->contentAvailable;
        }

        if (is_bool($this->mutableContent)) {
            $payload[self::PAYLOAD_ROOT_KEY][self::PAYLOAD_MUTABLE_CONTENT_KEY] = (int)$this->mutableContent;
        }

        if (is_string($this->category)) {
            $payload[self::PAYLOAD_ROOT_KEY][self::PAYLOAD_CATEGORY_KEY] = $this->category;
        }

        if (is_string($this->threadId)) {
            $payload[self::PAYLOAD_ROOT_KEY][self::PAYLOAD_THREAD_ID_KEY] = $this->threadId;
        }

        if (is_countable($this->customValues) && count($this->customValues)) {
            $payload = array_merge($payload, $this->customValues);
        }

        return $payload;
    }
280118
public function toJSON(){
        $outcomeValue = null;
        if($this->defaultValue != ''){
            $outcomeValue = Array($this->defaultValue);
        }else if($this->getAttributeValue('baseType') == 'integer' || $this->getAttributeValue('baseType') == 'float'){
            $outcomeValue = Array(0);
        }else{
            $outcomeValue = null;
        }

        $returnValue = taoQTI_models_classes_Matching_VariableFactory::createJSONVariableFromQTIData(
                        $this->getIdentifier()
                        , $this->getAttributeValue('cardinality')
                        , $this->getAttributeValue('baseType')
                        , $outcomeValue
        );

        return $returnValue;
    }
216642
protected function getPostedData()
    {
        $resourcePostedDataMode = $this->getResource()->getPostedDataMethod();
        $endpointPostedDataMode = $this->getEndpoint()->getPostedDataMethod();

        $postedDataMode = $resourcePostedDataMode;
        if ($endpointPostedDataMode != PostedDataMethods::AUTO) {
            $postedDataMode = $endpointPostedDataMode;
        }

        $postedData = null;

        switch ($postedDataMode) {

            case PostedDataMethods::POST:
                $postedData = $this->request->getPost();
                break;

            case PostedDataMethods::JSON_BODY:
                $postedData = $this->request->getJsonRawBody(true);
                break;

            case PostedDataMethods::AUTO:
            default:
                $postedData = $this->request->getPostedData($this->getEndpoint()->getHttpMethod());
        }

        return $postedData;
    }