|Last Updated|| ||Ratings|| ||Unique User Downloads|| ||Download Rankings|
|2017-09-11 (9 days ago) ||Not yet rated by the users||Total: 83 This week: 29||All time: 8,844 This week: 16|
This class create objects of classes mapped from JSON strings.
It can take a given class and extracts the annotations to determine the type of its variables.
The class can parse a JSON string and extracts the values to store in the class variables according to the types defined in the annotations.
The class can also retrieve nested objects to be stored in the class variables declared as such.
JOM - JSON Object Mapper
JOM is a powerful object mapper which maps JSON Data into PHP objects.
You can install this library using composer
$ composer require mintware-de/json-object-mapper
JOM is totally easy to use.
Simply put the annotation @MintWare\JOM\JsonField(name=, type=) to your class properties.
name is the name of the json property, type is the field type which can also be an mapped class.
For mapping you have to create an ObjectMapper-Object and call the mapJson Method
"street": "Mainstreet 22a",
"town": "Best Town"
/ @JsonField(name="first_name", type="string") */
/ @JsonField(name="surname", type="string") */
/ @JsonField(name="age", type="int") */
/ @JsonField(name="address", type="Some\Other\DataClass\Address") */
Map the JSON:
$mapper = new ObjectMapper();
$person = $mapper->mapJson(file_get_contents('person.json'), Person::class);
Feel free to fork, contribute and create pull requests
||Applications that use this package
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.