convert stdclass to json in php

Solutions on MaxInterview for convert stdclass to json in php by the best coders in the world

showing results for - "convert stdclass to json in php"
Pietro
01 Jan 2018
1$stdClass = new stdClass();
2$stdClass->name = "avatar";
3$stdClass->age = 31;
4$json_data = json_encode ((array) $stdClass);
5print_r($json_data); //{"name":"avatar","age":31}