|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
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-2024 The PHP Group
All rights reserved.
Last updated: Sat Feb 24 23:01:27 2024 UTC