php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #81109 JSON_UNQUTED_KEYS
Submitted: 2021-06-05 10:10 UTC Modified: 2021-06-05 11:03 UTC
From: engineering dot drmax24 at gmail dot com Assigned: cmb (profile)
Status: Wont fix Package: json (PECL)
PHP Version: 8.0.7 OS: any
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: engineering dot drmax24 at gmail dot com
New email:
PHP Version: OS:

 

 [2021-06-05 10:10 UTC] engineering dot drmax24 at gmail dot com
Description:
------------
Can you please:
1. add an option to send unquoted keys smth like JSON_UNQUTED_KEYS.
2. make json_decode to be able to decode json with unquoted keys. Now json_decode returns null if given a specification-correct json with no key quotes.

Json specification allows keys to be unquoted. If json keys are unquoted this saves up to 5-25% of json file size. 5-25% is a lot. 

This is a bit similar to JSON_UNESCAPED_UNICODE. If you send non-latin json safe chars with your utf8 webserver this is a big overhead in json file size. 5-25% too.

Test script:
---------------
json_encode(["a"=>"b"],JSON_UNQUOTED_KEYS|JSON_UNESCAPED_UNICODE);

Expected result:
----------------
{a:"b"}

Actual result:
--------------
{"a":"b"}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-05 10:53 UTC] marandall@php.net
The JSON specification does not allow unquoted keys therefore this is a request to produce invalid output.
 [2021-06-05 11:03 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-06-05 11:03 UTC] cmb@php.net
> Json specification allows keys to be unquoted.

No, see <https://datatracker.ietf.org/doc/html/rfc8259>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 02:01:28 2024 UTC