Re: JsonSerializable New Interface method Proposal
| From: | Dean Eigenmann | Date: | Mon, 13 Jul 2015 15:12:29 +0000 |
| Subject: | Re: JsonSerializable New Interface method Proposal | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-87150@lists.php.net to get a copy of this message | ||
Ryan,
I think the usage of this won't support multidimensional arrays.
However in the decode function,
You could specify
Foreach ($arr['permission'] as $permission) {
$this->permissions[] = (permission) json_decode($permission);
}
Sent from my iPhone
On 13 Jul 2015, at 17:03, Ryan Pallas <derokorian@gmail.com> wrote:
>>
>>>> Ive just opened a new RFC
>>>> https://wiki.php.net/rfc/jsonserializable
>>>> regarding Json to Object unserialization.
> I like the idea, but how do you handle complex json notations, that may contain arrays of
> objects? Say:
> {
> "id": 123
> "type": "user",
> "name": "derokorian"
> "permissions": [{
> "id": 1,
> "value": "create"
> },{
> "id": 2,
> "value": "edit"
> }]
> }
>
> Would this new function give me objects of type Permission in the permissions array, or would
> this solution only be a single level deep and therefore return an array of StdClass? I see no way to
> be able to tell this to the decoder in the User class because php does not support typed arrays.