PHP Class yii\web\JsonParser

To enable parsing for JSON requests you can configure [[Request::parsers]] using this class: php 'request' => [ 'parsers' => [ 'application/json' => 'yii\web\JsonParser', ] ]
Since: 2.0
Author: Dan Schmidt ([email protected])
Inheritance: implements yii\web\RequestParserInterface
Show file Open project: yiisoft/yii2 Class Usage Examples

Public Properties

Property Type Description
$asArray whether to return objects in terms of associative arrays.
$throwException whether to throw a BadRequestHttpException if the body is invalid json

Public Methods

Method Description
parse ( string $rawBody, string $contentType ) : array Parses a HTTP request body.

Method Details

parse() public method

Parses a HTTP request body.
public parse ( string $rawBody, string $contentType ) : array
$rawBody string the raw HTTP request body.
$contentType string the content type specified for the request body.
return array parameters parsed from the request body

Property Details

$asArray public property

whether to return objects in terms of associative arrays.
public $asArray

$throwException public property

whether to throw a BadRequestHttpException if the body is invalid json
public $throwException