PHP code example of pengfugui / jsongenerator
1. Go to this page and download the library: Download pengfugui/jsongenerator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pengfugui / jsongenerator example snippets
$generator = new ClassGenerator();
$json = <<<JSON
{"attribute" : "属性", "int_var":1,"bool_var":true,"ad_models" : [{"test":"a"}]}
JSON;
$ret = $generator->parseByJson($json, $className, $namespace);
foreach ($generator->getClassModels() as $model) {
$list[] = [
'class_name' => $model->getClassName(),
'namespace' => $model->getNamespace(),
'code' => code2HtmlEntity($model->getClassCode())
];
}