35 const DEFAULT_JSON_FLAGS = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_UNESCAPED_SLASHES;
58 $encodingOptions = self::DEFAULT_JSON_FLAGS
69 $this->headers[
'Content-Type'][] =
'application/json; charset=utf-8';
70 $this->lowercasedHeaderNames[
'content-type'] =
'Content-Type';
83 $this->body->write($this->
jsonEncode($data, $encodingOptions));
84 $this->body->rewind();
98 if (is_resource($data)) {
99 throw new \InvalidArgumentException(
'Cannot JSON encode resources', 1504972433);
103 $json = json_encode($data, $encodingOptions);
104 if (JSON_ERROR_NONE !== json_last_error()) {
105 throw new \InvalidArgumentException(sprintf(
106 'Unable to encode data to JSON in %s: %s',
108 json_last_error_msg()