What are some common pitfalls when using json_encode in PHP?

One common pitfall when using json_encode in PHP is that it may not handle special characters properly, leading to potential encoding issues. To solve this problem, you can use the JSON_UNESCAPED_UNICODE option to ensure that Unicode characters are properly encoded.

$data = array("name" => "John Döe");
$json = json_encode($data, JSON_UNESCAPED_UNICODE);
echo $json;