Re: Removing basic types from our JSON parser

From: Date: Sun, 14 Dec 2008 08:18:04 +0000
Subject: Re: Removing basic types from our JSON parser
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-42248@lists.php.net to get a copy of this message
Do you mean a json_parse in javascript (like a better eval() I assume)? Thats what we were doing. Json is not supposed to be pure javascript either, but a serialized representation of variables like php's serialize(). So I would not expect a json string to be usable without using eval or something else in javascript first. We had to modify the php json_encode output to be wrapped with a couple extra braces for it to be able to be consumed properly on javascript (or maybe it was the other way around) - I just want to make sure we won't have to make special things like that in the future. On Dec 13, 2008, at 10:52 PM, Rasmus Lerdorf <rasmus@lerdorf.com> wrote:
Yes, but that would be going to a json_parse thing somewhere, not pure Javascript. -Rasmus mike wrote:
I can't give specifics (I'm mobile and I don't remember where the code would be anyway) but we had an issue with php and javascript exchange via json where the php output using json_encode and we had to wrap it with additional braces for it to be usable. Sorry for being vague, this thread reminded me of that which is why I wanted to voice off. Thanks for the clarification (and thank you so much for PHP :)) On Dec 13, 2008, at 10:39 PM, Rasmus Lerdorf <rasmus@lerdorf.com> wrote:
mike wrote:
Sorry for top posting. I see no reason why php should not interop with javascript 100% as it should. I do not see a reason to create new functions, parameters, etc. The existing should be expected to both encode and decode json with javascript properly. If there is a mismatch right now, then it should be fixed.
There is no mismatch with Javascript now at all. We spit out perfectly valid Javascript. There is only a slight mismatch with the JSON RFC which defines a stricter subset of Javascript than we are using. -Rasmus


« previous php.internals (#42248) next »