php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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
Description:
------------
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}};
json_encode($p['object']);

After conversion i get

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

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-03 17:18 UTC] cmb@php.net
> 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] cmb@php.net
-Status: Open +Status: Closed -Package: *General Issues +Package: JSON related -Assigned To: +Assigned To: cmb
 [2021-06-03 17:51 UTC] cmb@php.net
Well, then this is obviously not a PHP bug.
 [2021-06-03 17:52 UTC] cmb@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Dec 01 18:05:54 2022 UTC