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
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.
Password:
Status:
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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 00:01:30 2024 UTC