Tobscure\JsonApi\Document::jsonSerialize PHP Method

jsonSerialize() public method

Serialize for JSON usage.
public jsonSerialize ( ) : array
return array
    public function jsonSerialize()
    {
        return $this->toArray();
    }

Usage Example

Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function __construct(Document $document, $status = 200, array $headers = [], $encodingOptions = 15)
 {
     $headers['content-type'] = 'application/vnd.api+json';
     // The call to jsonSerialize prevents rare issues with json_encode() failing with a
     // syntax error even though Document implements the JsonSerializable interface.
     // See https://github.com/flarum/core/issues/685
     parent::__construct($document->jsonSerialize(), $status, $headers, $encodingOptions);
 }