Class yii\httpclient\JsonParser

Inheritanceyii\httpclient\JsonParser » yii\base\BaseObject
Implementsyii\httpclient\ParserInterface
Available since extension's version2.0
Source Code https://github.com/yiisoft/yii2-httpclient/blob/master/src/JsonParser.php

JsonParser parses HTTP message content as JSON.

Public Properties

Hide inherited properties

Property Type Description Defined By
$asArray boolean Whether to return objects in terms of associative arrays. yii\httpclient\JsonParser

Public Methods

Hide inherited methods

Method Description Defined By
parse() Parses given HTTP response instance. yii\httpclient\JsonParser

Property Details

Hide inherited properties

$asArray public property (available since version 2.0.8)

Whether to return objects in terms of associative arrays.

public boolean $asArray true

Method Details

Hide inherited methods

parse() public method

Parses given HTTP response instance.

public mixed parse ( yii\httpclient\Response $response )
$response yii\httpclient\Response

HTTP response instance.

return mixed

Parsed content data.

                public function parse(Response $response)
{
    return Json::decode($response->getContent(), $this->asArray);
}