How does PHP calculate JSON length

for example, how to judge whether the length of JSON reaches three. If only MCVersion,JavaVersion lacks Server, it indicates that JSON is incomplete. How to implement

{"MCVersion":"v1.10.0","JavaVersion":"v1.8","Server":"Linux"}
Jun.04,2021

The

json object is the structure of a class array, and the sizeof function can be used to determine the length

.
$data1=json_decode('{"MCVersion":"v1.10.0","JavaVersion":"v1.8","Server":"Linux"}', true);

var_dump($data1);
echo sizeof($data1);

will output

array(3) {                                                                                   
  ["MCVersion"]=>                                                                            
  string(7) "v1.10.0"                                                                        
  ["JavaVersion"]=>                                                                          
  string(4) "v1.8"                                                                           
  ["Server"]=>                                                                               
  string(5) "Linux"                                                                          
}                                                                                            
3

Note that the second parameter of json_decode will return array type if you want to use true,. You can use sizeof, otherwise it will return stdClass.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e42260-4c098.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e42260-4c098.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?