There are cases where our API returns to us an empty response (Unsubscribe from List being an example).
Any php version > 7 will throw a JSON_ERROR_SYNTAX (4) If an empty string is passed.
To solve the issue, we should check if the response is empty. If it is, instead of decoding the response we should decode an empty object. To keep the function consistent, I've added true as the second argument to return an empty array.
The logic has been tested on php 7.3
I've attached 2 screenshots showing int(4) being returned currently, and 0 (no error) after the update.
There are cases where our API returns to us an empty response (Unsubscribe from List being an example). Any php version > 7 will throw a
JSON_ERROR_SYNTAX
(4) If an empty string is passed. To solve the issue, we should check if the response is empty. If it is, instead of decoding the response we should decode an empty object. To keep the function consistent, I've added true as the second argument to return an empty array.The logic has been tested on php 7.3 I've attached 2 screenshots showing int(4) being returned currently, and 0 (no error) after the update.