Model::toJson( $options )


Source

File: Model/Model.php

	public function toJson( $options = 0 ) {

		$json = json_encode( $this->toArray(), $options );

		if ( JSON_ERROR_NONE !== json_last_error() ) {

			throw new \Exception( 'Error encoding model [' . get_class( $this ) . '] to JSON: '
			                      . json_last_error_msg() );

		}

		return $json;
	}