|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81102 json integer is converted to string
Submitted: 2021-06-03 16:49 UTC Modified: 2021-06-03 17:51 UTC
From: kumar dot muthaiah at yahoo dot com Assigned: cmb (profile)
Status: Not a bug Package: JSON related
PHP Version: 7.4Git-2021-06-03 (Git) OS: linux
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: kumar dot muthaiah at yahoo dot com
New email:
PHP Version: OS:


 [2021-06-03 16:49 UTC] kumar dot muthaiah at yahoo dot com
json integer is converted to string in wordpress php 7.4 version for json_encode() function. Causes javascript in client side to not load the component that depends on json. I'm using Wordopress REST API.

Test script:
$p = {"id:": 1, "object": {"name": "kumar", "age": 10, "married": false}};

After conversion i get

{"name": "kumar", "age": "10", "married": "false"}

Actual result:
{"name": "kumar", "age": 10, "married": false}


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-03 17:18 UTC]
> After conversion i get

I get a syntax error even before conversion.
 [2021-06-03 17:39 UTC] kumar dot muthaiah at yahoo dot com
The problem is wordpress REST API which converts json integers to strings.PHP is doing fine. i've modified the known parameters by converting to respective types before sending to json_encode(). working fine.
 [2021-06-03 17:51 UTC]
-Status: Open +Status: Closed -Package: *General Issues +Package: JSON related -Assigned To: +Assigned To: cmb
 [2021-06-03 17:51 UTC]
Well, then this is obviously not a PHP bug.
 [2021-06-03 17:52 UTC]
-Status: Closed +Status: Not a bug
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 13 17:01:30 2024 UTC