safe icon indicating copy to clipboard operation
safe copied to clipboard

Clear previous error for json_decode

Open nepda opened this issue 2 years ago • 0 comments

If you (or your framework) calls the native json_decode function with an invalid JSON string, it will save the last error in json_last_error().

If you then call the Safe function, you will get an error on a valid JSON.

The solution could be to call the native json_decode function once with a valid JSON to clear the last error.

Copied from: https://github.com/laravel/framework/pull/42125/files#diff-35f0fed0fb4be3d1d696cb36c7266cd36daed1aa31c9f74394c38620620776b4R77

nepda avatar May 10 '23 09:05 nepda