多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] > [github](https://github.com/cweiske/jsonmapper) ## 安装 `composer require netresearch/jsonmapper` ## 使用 ``` $json='{"name":"Sheldon Cooper","address":{"street":"2311 N. Los Robles Avenue","city":"Pasadena"}}'; class Contact { /** * Full name * @var string */ public $name; /** * @var Address */ public $address; } class Address { public $street; public $city; public function getGeoCoords() { echo "hello word:===".$this->city."==="; } } $mapper = new JsonMapper(); $contact = $mapper->map(json_decode($json), new Contact()); $contact->address->getGeoCoords();//hello word:===Pasadena=== ```