📅  最后修改于: 2022-03-11 14:53:56.796000             🧑  作者: Mango
$stdClass = new stdClass();
$stdClass->name = "avatar";
$stdClass->age = 31;
$json_data = json_encode ((array) $stdClass);
print_r($json_data); //{"name":"avatar","age":31}