You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default all public properties of the class will be inspected. For all properties that have a json key with the same name the according value will be set.
18
+
By default all public properties of the class will be inspected. For all properties that have a JSON key with the same name the according value will be set.
19
19
20
20
### A simple example
21
21
Assume you have a class `Person` that looks like this:
22
22
```php
23
-
class Person {
23
+
class Person
24
+
{
24
25
public $id;
25
26
public $name;
26
27
}
27
28
```
28
29
29
-
The following code will transform the given json data into an instance of `Person`.
30
+
The following code will transform the given JSON data into an instance of `Person`.
@@ -81,6 +83,17 @@ The `JsonDecoder` class accepts two boolean constructor parameters to enable the
81
83
82
84
To do so a so called `PropertyAccessor` will be installed and on property set the proxy will set the property to accessible, set the according value and then will set the property to not accessible again.
83
85
86
+
### Transforming an array of elements
87
+
If your JSON contains an array of elements at the root level you can use the `decodeMultiple` method to transform the JSON data into an array of class type objects.
0 commit comments