php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #81138 json_encode doesn't mention dtring could be returned
Submitted: 2021-06-14 16:48 UTC Modified: 2021-06-14 16:54 UTC
From: tim dot d dot whitney at gmail dot com Assigned: danack (profile)
Status: Not a bug Package: Documentation problem
PHP Version: 7.4.20 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
9 + 9 = ?
Subscribe to this entry?

 
 [2021-06-14 16:48 UTC] tim dot d dot whitney at gmail dot com
Description:
------------
---
From manual page: https://php.net/function.json-decode
---

>>> json_decode('"{\"test\": 123}"', TRUE);
=> "{"test": 123}"

The documentation does not mention that a string could be returned.

Test script:
---------------
>>> json_decode('"{\"test\": 123}"', TRUE);
=> "{"test": 123}"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-14 16:54 UTC] danack@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: danack
 [2021-06-14 16:54 UTC] danack@php.net
I don't think it needs to do that, as string is the "appropriate PHP type." sometimes.

var_dump(json_decode(json_encode('"{\"test\": 123}"'), TRUE));

If you want to propose some better wording, please do so at:
https://github.com/php/doc-en/blob/master/reference/json/functions/json-decode.xml
 [2021-06-14 16:54 UTC] danack@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 07:01:28 2024 UTC