@@ -151,7 +151,7 @@ interface_exists('JsonSerializable', false) &&
151
151
$ data instanceof \JsonSerializable
152
152
)
153
153
)) {
154
- $ data = \Curl \json_encode ($ data );
154
+ $ data = \Curl \Encoder:: encodeJson ($ data );
155
155
} elseif (is_array ($ data )) {
156
156
// Manually build a single-dimensional array from a multi-dimensional array as using curl_setopt($ch,
157
157
// CURLOPT_POSTFIELDS, $data) doesn't correctly handle multi-dimensional arrays when files are
@@ -1760,34 +1760,3 @@ function createHeaderCallback($header_callback_data) {
1760
1760
return strlen ($ header );
1761
1761
};
1762
1762
}
1763
-
1764
- /**
1765
- * Json Encode
1766
- *
1767
- * Wrap json_encode() to throw error when the value being encoded fails.
1768
- *
1769
- * @param $value
1770
- * @param $options
1771
- * @param $depth
1772
- *
1773
- * @return string
1774
- * @throws \ErrorException
1775
- */
1776
- function json_encode ($ value , $ options = 0 , $ depth = 512 ) {
1777
- // Make compatible with PHP version both before and after 5.5.0. PHP 5.5.0 added the $depth parameter.
1778
- $ gte_v550 = version_compare (PHP_VERSION , '5.5.0 ' ) >= 0 ;
1779
- if ($ gte_v550 ) {
1780
- $ value = \json_encode ($ value , $ options , $ depth );
1781
- } else {
1782
- $ value = \json_encode ($ value , $ options );
1783
- }
1784
- if (!(json_last_error () === JSON_ERROR_NONE )) {
1785
- if (function_exists ('json_last_error_msg ' )) {
1786
- $ error_message = 'json_encode error: ' . json_last_error_msg ();
1787
- } else {
1788
- $ error_message = 'json_encode error ' ;
1789
- }
1790
- throw new \ErrorException ($ error_message );
1791
- }
1792
- return $ value ;
1793
- }
0 commit comments