[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=== ```