|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2017-01-25 12:20 UTC] requinix@php.net
 
-Assigned To:
+Assigned To: pollita
  [2017-01-25 12:20 UTC] requinix@php.net
  [2017-01-25 14:39 UTC] kruithne at gmail dot com
  [2017-03-17 22:26 UTC] pollita@php.net
  [2017-03-17 22:39 UTC] pollita@php.net
 
-Status: Assigned
+Status: Closed
  [2017-03-17 22:39 UTC] pollita@php.net
 | |||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 01:00:01 2025 UTC | 
Description: ------------ The documentation states that the fourth parameter for json_decode() is a bit-mask value, it goes on to list two possible flags: JSON_OBJECT_AS_ARRAY and JSON_BIGINT_AS_STRING. Despite being redundant (superseded by the second parameter), the JSON_OBJECT_AS_ARRAY flag has no effect on the decoded result when supplied. Test script: --------------- <?php $json = '{"test": "From there to here, and here to there, funny things are everywhere.", "number": 12345678901234567890}'; // Prove json_decode is working by default. // Expected: object(stdClass) (2) {["test"] => string(67) ["number"] => float()} // Result: object(stdClass) (2) {["test"] => string(67) ["number"] => float()} $decoded = json_decode($json); var_dump($decoded); // Prove that passing bit-mask options works. // Expected: object(stdClass) (2) {["test"] => string(67) ["number"] => string(20)} // Result: object(stdClass) (2) {["test"] => string(67) ["number"] => string(20)} $decoded = json_decode($json, false, 512, JSON_BIGINT_AS_STRING); var_dump($decoded); // Prove that the second parameter works for associative conversion. // Expected: array(2) {["test"] => string(67) ["number"] => string(20)} // Result: array(2) {["test"] => string(67) ["number"] => string(20)} $decoded = json_decode($json, true, 512, JSON_BIGINT_AS_STRING); var_dump($decoded); // Attempt to use JSON_OBJECT_AS_ARRAY for associative conversion fails. // Expected: array(2) {["test"] => string(67) ["number"] => string(20)} // Result: object(stdClass) (2) {["test"] => string(67) ["number"] => string(20)} $decoded = json_decode($json, false, 512, JSON_OBJECT_AS_ARRAY); var_dump($decoded); Expected result: ---------------- object(stdClass) (2) {["test"] => string(67) ["number"] => float()} object(stdClass) (2) {["test"] => string(67) ["number"] => string(20)} array(2) {["test"] => string(67) ["number"] => string(20)} array(2) {["test"] => string(67) ["number"] => string(20)} Actual result: -------------- object(stdClass) (2) {["test"] => string(67) ["number"] => float()} object(stdClass) (2) {["test"] => string(67) ["number"] => string(20)} array(2) {["test"] => string(67) ["number"] => string(20)} object(stdClass) (2) {["test"] => string(67) ["number"] => string(20)}