# json_object **Repository Path**: stlswm/json_object ## Basic Information - **Project Name**: json_object - **Description**: php解析json格式字符串到目标对象中 - **Primary Language**: PHP - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2019-06-03 - **Last Updated**: 2022-05-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 实现php json_decode的强类型解析 #### Description php解析json格式字符串到指定的对象中 #### Software Architecture php解析json格式字符串到指定的对象中,实现json的强类型解析。 #### Installation composer require stlswm/json-object #### Instructions 应用举例 一、json编码 ``` InvoiceCreateDataRes::class, ]; } ``` 属性是一维数组: ``` /** * @return array */ public function getClassMap(): array { return [ 'data' => [ InvoiceCreateDataRes::class ], ]; } ``` 属性是二维数组: ``` /** * @return array */ public function getClassMap(): array { return [ 'data' => [ [ InvoiceCreateDataRes::class ] ], ]; } ``` 以此类推 类申明举例 ```$xslt InvoiceCreateDataRes::class, ]; } } ``` 2.2、json字符串反解析用法 应用举例: ``` request('/base/oauth/token', $accessTokenReq); $bool = Json::unMarshal($response, $accessTokenRes); if (!$bool) { throw new Exception('无法解析返回:' . $response); } return $accessTokenRes; } } ``` 三、可参考项目:https://github.com/stlswm/piao_zone 中src/Response中类的写法 #### Contribution 1. Fork the repository 2. Create Feat_xxx branch 3. Commit your code 4. Create Pull Request #### Gitee Feature 1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md 2. Gitee blog [blog.gitee.com](https://blog.gitee.com) 3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) 4. The most valuable open source project [GVP](https://gitee.com/gvp) 5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) 6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)