Welcome Guest, Not a member yet? Register   Sign In
CURLRequest Class Failed to parse json string
#1

I am using CURLRequest class, to receive data from an API, sometimes I get this message

Code:
<b>Fatal error</b>:  Uncaught CodeIgniter\Format\Exceptions\FormatException: Failed to parse json string, error: &quot;Malformed UTF-8 characters, possibly incorrectly encoded&quot;. in /Users/userName/Sites/MySite/vendor/codeigniter4/framework/system/Format/JSONFormatter.php:41

followed by the stack trace

I understand the message, even if the returned json does not depend on me but on the API, is there a way to still be able to see what is returned from the API in order to understand the problem and possibly report the problem to the API manager?
Reply
#2

Add dd() to see the variable before the line of the error.
https://codeigniter4.github.io/CodeIgnit...ng.html#dd
Reply
#3

(11-17-2022, 05:55 PM)kenjis Wrote: Add dd() to see the variable before the line of the error.
https://codeigniter4.github.io/CodeIgnit...ng.html#dd

but the error line of the JSONFormatter.php file?
Reply
#4

(11-18-2022, 02:11 AM)serialkiller Wrote: but the error line of the JSONFormatter.php file?

Yes. Why don't you?

Or run step debugging and stop the execution before the error line.
Reply
#5

(11-18-2022, 03:15 AM)kenjis Wrote:
(11-18-2022, 02:11 AM)serialkiller Wrote: but the error line of the JSONFormatter.php file?

Yes. Why don't you?

Or run step debugging and stop the execution before the error line.

I'll try Smile

Thanks kenjis
Reply
#6

PHP Code:
dd();
exit(); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

I'm still here, i tried to put
PHP Code:
dd() 

and also

PHP Code:
dd();
exit; 

before line 41 where the error is reported, but I don't see anything.

I set the value of CI_DEBUG to true as the guide says, but my toolbar is disabled for ajax calls.

What am I doing wrong?
Reply
#8

Pass the variable you want to see to dd().
Reply




Theme © iAndrew 2016 - Forum software by © MyBB