mike wrote:
> 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.

Eh?  Read what you wrote there.  If json wasn't pure javascript, how in
the world would eval() work on it?

Douglas Crockford likes to say that he didn't invent json, he discovered
it.  It was already there because it is just javascript.  He just
started using it.

<script>
var foo = <?php echo json_encode($foo)?>;
</script>

will always work.  The only question is what sort of variable foo will
end up being.  The RFC says we have to wrap basic types in an array or
object, while currently we let the basic types through without the wrapper.

-Rasmus

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to