Re: [PHP-DEV] JsonSerializable New Interface method Proposal

2015-07-13 Thread Jakub Zelenka
Hi On 13 Jul 2015 14:23, "Dean Eigenmann" wrote: > > Ive just opened a new RFC https://wiki.php.net/rfc/jsonserializable regarding Json to Object unserialization. As it's been said, the first part (casting) is a no-go. It would have to be done in a run time by scanning of opcode array which is n

Re: [PHP-DEV] JsonSerializable New Interface method Proposal

2015-07-13 Thread Sara Golemon
On Mon, Jul 13, 2015 at 8:03 AM, Ryan Pallas 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

Re: [PHP-DEV] JsonSerializable New Interface method Proposal

2015-07-13 Thread Aaron Piotrowski
> On Jul 13, 2015, at 1:56 PM, Dean Eigenmann wrote: > > I have updated the RFC with a new section showing the updates > > Sent from my iPhone > >> On 13 Jul 2015, at 20:47, Benjamin Eberlei wrote: >> >> On Mon, Jul 13, 2015 at 3:22 PM, Dean Eigenmann >> wrote: >> >>> Ive just opened a new

Re: [PHP-DEV] JsonSerializable New Interface method Proposal

2015-07-13 Thread Dean Eigenmann
I have updated the RFC with a new section showing the updates Sent from my iPhone > On 13 Jul 2015, at 20:47, Benjamin Eberlei wrote: > > On Mon, Jul 13, 2015 at 3:22 PM, Dean Eigenmann > wrote: > >> Ive just opened a new RFC https://wiki.php.net/rfc/jsonserializable regarding >> Json to Obje

Re: [PHP-DEV] JsonSerializable New Interface method Proposal

2015-07-13 Thread Benjamin Eberlei
On Mon, Jul 13, 2015 at 3:22 PM, Dean Eigenmann wrote: > Ive just opened a new RFC https://wiki.php.net/rfc/jsonserializable regarding > Json to Object unserialization. > The approach with typecasting will not work, because the function json_decode doesn't have that information. Instead somethi

Re: [PHP-DEV] JsonSerializable New Interface method Proposal

2015-07-13 Thread Dean Eigenmann
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 wro

Re: [PHP-DEV] JsonSerializable New Interface method Proposal

2015-07-13 Thread Dean Eigenmann
I will update the spec for it to be a function, called something like json_decode_to($json, $class, $mapping = []); With mapping you could then specify with array keys map to which class property. Sent from my iPhone > On 13 Jul 2015, at 16:59, Rowan Collins wrote: > > guilhermebla...@gmail.c

Re: [PHP-DEV] JsonSerializable New Interface method Proposal

2015-07-13 Thread Ryan Pallas
> > > 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" "permissio

Re: [PHP-DEV] JsonSerializable New Interface method Proposal

2015-07-13 Thread Rowan Collins
guilhermebla...@gmail.com wrote on 13/07/2015 15:19: What about JsonDeserializable? I would like to have the choice to have a serialize-only operation. Yeah, this would need to be a new interface, because interfaces can't have optional methods, so changing the existing interface would instant

Re: [PHP-DEV] JsonSerializable New Interface method Proposal

2015-07-13 Thread Dean Eigenmann
I think the suggested decode function would be the best way to handle this. On Jul 13, 2015, at 04:20 PM, "guilhermebla...@gmail.com" wrote: What about JsonDeserializable? I would like to have the choice to have a serialize-only operation. On Mon, Jul 13, 2015 at 10:13 AM, Dean Eigenmann wro

Re: [PHP-DEV] JsonSerializable New Interface method Proposal

2015-07-13 Thread guilhermebla...@gmail.com
What about JsonDeserializable? I would like to have the choice to have a serialize-only operation. On Mon, Jul 13, 2015 at 10:13 AM, Dean Eigenmann wrote: > The Additional function you have proposed seems like the easiest and best > way to do it currently without changing the language. I was thi

Re: [PHP-DEV] JsonSerializable New Interface method Proposal

2015-07-13 Thread Dean Eigenmann
The Additional function you have proposed seems like the easiest and best way to do it currently without changing the language. I was thinking of giving the cast syntax special meaning if used in connection with json_decode, but this would most likely be near to impossible. On Jul 13, 2015, at

Re: [PHP-DEV] JsonSerializable New Interface method Proposal

2015-07-13 Thread Sebastian B.-Hagensen
Hi, I like the general idea behind that proposal. I'm not sure how you would want to implement that however (please expand the rfc on that topic). Do you want to give the cast syntax a special meaning if used in connection with json_decode or add the general ability to cast a stdClass object (as