|  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
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:
Solve the problem:
15 + 30 = ?
Subscribe to this entry?

 [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 17:01:30 2023 UTC