json_decode

PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL json >= 1.2.0
json_decode - Decodes a JSON string

Example #1 <span class='function-parameter'>depth</span> errors

Result: array(1) { [1]=> array(2) { ["English"]=> array(2) { [0]=> string(3) "One" [1]=> string(7) "January" } ["French"]=> array(2) { [0]=> string(3) "Une" [1]=> string(7) "Janvier" } } } Last error: No error NULL Last error: Maximum stack depth exceeded
PHP Version:

Example #2 json_decode examples

Result: object(stdClass)#1 (5) { ["a"] => int(1) ["b"] => int(2) ["c"] => int(3) ["d"] => int(4) ["e"] => int(5) } array(5) { ["a"] => int(1) ["b"] => int(2) ["c"] => int(3) ["d"] => int(4) ["e"] => int(5) }
PHP Version:

Example #3 json_decode of large integers

Result: object(stdClass)#1 (1) { ["number"]=> float(1.2345678901235E+19) } object(stdClass)#1 (1) { ["number"]=> string(20) "12345678901234567890" }
PHP Version:

Example #4 Accessing invalid object properties

PHP Version:

Example #5 common mistakes using json_decode

PHP Version:


Example #6 of json_decode

PHP Version:


Function json_decode:

JavaScript Object Notation Functions

Most used PHP functions