|  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
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: 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-2023 The PHP Group
All rights reserved.
Last updated: Thu Nov 30 02:01:27 2023 UTC