Parse the response.

@param $responseInJson
961953
protected function parseResponse($responseInJson)
    {
        $this->parse($responseInJson);

        if ($this->needResultParsing($responseInJson)) {
            $this->parseResult($responseInJson);
        }

        if ($this->logEnabled) {
            $this->logResponse();
        }
    }
1042331
private function parse() {
        $data = json_decode($this->httpResponse->getBody(), true);

        foreach ($data['messages'] as $message) {
            $msg = new Message($message);
            $this->messages[] = $msg;

            if ($message['type'] === 'error' || $message['type'] === 'non-document-error') {
                $this->errors[] = $msg;
            } else if ($message['type'] === 'warning') {
                $this->warnings[] = $msg;
            }
        }
    }
1358142
private function parseResponse(
        $response_body,
        $response_code,
        $response_headers
    ) {
        $resp = null;
        if ($response_body) {
            $resp      = json_decode($response_body, true);
            $jsonError = json_last_error();
            if ($resp === null && $jsonError !== JSON_ERROR_NONE) {
                $msg = "Invalid response body: $response_body "
                    . "(HTTP response code: $response_code, json_last_error: $jsonError)";
                throw new ApiException($msg, $response_code,
                    $response_body);
            }
        }

        if ($response_code < 200 || $response_code >= 300) {
            $this->handleApiError($response_body, $response_code,
                $response_headers, $resp);
        }

        return $resp;
    }
22046
protected function parseCurlResponse($response)
    {
        $pattern = '|HTTP/\d\.\d.*?$.*?\r\n\r\n|ims';
        preg_match($pattern, $response, $matches);
        $header = $matches[0];
        // Remove headers from the response body
        $body = str_replace($header, '', $response);

        return [
            'header' => $header,
            'body' => $body
        ];
    }
1039264
public function parseData(array $response)
    {
        $key = str_replace('.', '_', $this->getMethod()) . '_response';
        return array_key_exists($key, $response) ? $response[$key] : null;
    }
1342830
protected function normalizeResponse(ResponseInterface $response)
    {
        if (!is_null($this->normalizer)) {
            return $this->normalizer->normalize($response);
        }

        //default responsen is decoded json
        return $response->json();
    }
1114709
function decodeJSON($json)
    {
        $json_response = json_decode($json);
        if ($json_response === null) {
            throw new Clientside\Exception("Unable to decode JSON response from: {$json}");
        }
        return $json_response;
    }
702820
public static function parseResponse(Response $response)
    {
        $jsonData = \GuzzleHttp\json_decode($response->getBody(), true);
        if ($jsonData && 0 == $jsonData['retcode']) {
            return $jsonData['result']['account'];
        }
        throw new ResponseException($jsonData['retcode'], $response);
    }
658444
private function parseResult($responseInJson)
    {
        foreach ($responseInJson[self::RESULTS] as $index => $result) {
            if (!$this->isSent($result)) {
                if (!$this->needToBeModify($index, $result)) {
                    if (!$this->needToBeDeleted($index, $result) && !$this->needToResend($index, $result) && !$this->checkMissingToken($result)) {
                        $this->needToAddError($index, $result);
                    }
                }
            }
        }
    }
1132630
protected function parse_json( $json ) {

		$data = json_decode( $json, true );

		if ( ! is_array( $data ) ) {
			$data = array();
		}

		return $data;
	}
155275
private function parse($response)
    {
        // Explode the response into headers and body parts (separated by double EOL)
        list($headers, $response) = explode("\r\n\r\n", $response, 2);
        
        // Explode response headers
        $lines = explode("\r\n", $headers);
        
        // If the status code is 100, the API server must send a final response
        // We need to explode the response again to get the actual response
        if (preg_match('#^HTTP/1.1 100#', $lines[0])) {
            list($headers, $response) = explode("\r\n\r\n", $response, 2);
            $lines = explode("\r\n", $headers);
        }
        
        // Get the HTTP response code from the first line
        $first = array_shift($lines);
        $pattern = '#^HTTP/1.1 ([0-9]{3})#';
        preg_match($pattern, $first, $matches);
        $code = $matches[1];
        
        // Parse the remaining headers into an associative array
        $headers = array();
        foreach ($lines as $line) {
            list($k, $v) = explode(': ', $line, 2);
            $headers[strtolower($k)] = $v;
        }
        
        // If the response body is not a JSON encoded string
        // we'll return the entire response body
        if (!$body = json_decode($response)) {
            $body = $response;
        }
        
        return array('code' => $code, 'body' => $body, 'headers' => $headers);
    }
1115719
private function parseResponse(ResponseInterface $response = null): array
    {
        $body = $response
            ? (string) $response->getBody()
            : null;

        return $body
            ? guzzle_json_decode($body, true)
            : [];
    }
792540
protected function parseResponse($responseInJson)
    {
        if (!$this->parseSuccess($responseInJson)) {
            $this->parseError($responseInJson);
        }

        if ($this->logEnabled) {
            $this->logResponse();
        }
    }
1358918
private function _parseResponse(Response $response)
    {
        switch ($this->_format) {
            case self::FORMAT_JSON:
                return json_decode($response, $this->_isJsonDecodeAssoc);
                break;
            default:
                return $response;
        }
    }
177678
protected function parseResponse(Response $response)
    {
        $contentType = explode(';', $response->getHeader('content-type'))[0];

        switch ($contentType) {
            case 'application/json':
            case 'application/vnd.api+json':
                return $response->json();

            case 'application/xml':
                return $response->xml();
        }

        throw new RuntimeException("Unsupported returned content-type [$contentType]");
    }
574998
private function parseSuccess($responseInJson)
    {
        if (array_key_exists(self::MESSAGE_ID, $responseInJson)) {
            $this->messageId = $responseInJson[ self::MESSAGE_ID ];
        }
    }
964132
public static function makeFromJson(JsonResponse $json)
    {
        $content = $json->getContent();

        // If the contents of the JsonResponse does not starts with /**/ (typical laravel jsonp response)
        // we assume that it is a valid json response that can be decoded, or we just use the raw jsonp
        // contents for building the response
        if (! Str::startsWith($json->getContent(), '/**/')) {
            $content = \json_decode($json->getContent(), true);
        }

        $new = static::create($content, $json->getStatusCode());

        $new->headers = $json->headers;

        return $new;
    }