What’s wrong with this code?
$a = Array (
"password" => "SeRjQRVUglkeM‰‰P9L7NsjKXOY", //it's encrypted with a custom encryption system
"id" => 0
);
echo json_encode($a);
What am I getting:
{"password":null,"id":0}
What is the output i want:
{"password":"SeRjQRVUglkeM‰‰P9L7NsjKXOY","id":0}
json_encodeexpects valid UTF-8 and will not encode values which are not valid UTF-8. If your “custom encrypted values” contain binary data, as I assume, it’s not safe for transport via JSON. You shouldbase64_encodethe value, so it uses transportable ASCII characters only.