|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63152 json_encode does not work on binary strings
Submitted: 2012-09-24 15:14 UTC Modified: 2012-09-24 16:50 UTC
From: staff at newsocialife dot com Assigned:
Status: Not a bug Package: JSON related
PHP Version: 5.3.17 OS: Ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: staff at newsocialife dot com
New email:
PHP Version: OS:


 [2012-09-24 15:14 UTC] staff at newsocialife dot com
So, I have an array witch doesn't encode right in json...
( look the example script... )

Test script:
$a = Array (
    "password" => "SeRjQRVUglkeM‰‰P9L7NsjKXOY", //it's encrypted with a custom encryption system
    "id" => 0
echo json_encode($a);

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-24 15:24 UTC]
-Status: Open +Status: Not a bug
 [2012-09-24 15:24 UTC]
JSON as per RFC-4626 cannot encode arbitrary binary data. Everything you pass to 
json_encode() must be valid Unicode. json_last_error() would have told you this.
 [2012-09-24 16:50 UTC]
-Summary: Json is going stupid +Summary: json_encode does not work on binary strings
 [2012-09-24 16:50 UTC]
Also, would be nice if you could provide a more meaningful title next time :) Btw, if you want to encode binary data as JSON (or basically anything else) you should first base64_encode it.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Jan 28 00:04:48 2023 UTC