json-php on slashdot

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

In my journal anyway:

"JSON: Javascript Unusable by the Client"


Re: json-php on slashdot

Quoted text here. Click to load it

I must admit, I fail to see the point of your journal entry. It appears
to try to point out problems with JSON, but which problems? And are
they JSON problems or strawmen? (I'm leaning towards the latter).

quote: "This same sample data file specified as the src attribute of a
script tag results in a page throwing a Javascript error"

Well, what did you expect?

JSON is a *value* description language. It is a subset of ECMAScript's
literal notation, which is *expression* syntax. When you try loading
and evaluating it as a statement, it fails.

If you fetch the text using XMLHttpRequest and evaluates it using
"eval", then it works perfectly (and if you are targeting a browser
only, it's a much better format to send your data in than, e.g., XML).

You have a language for expression values. You want these values to
be available to your code, so you must have some way of getting the
text and parsing it.

*One* such way is to put the *JSON* text into a *Javascript*
assignment and load the assignment into a script tag on a web page.
That does not make the assignment part of the JSON value, nor
does it need to be.

But, looking at the *first* answer in the PHP-JSON thread linked to,
all this has already been said.

Ah, I now see that you are the "scriptify" of that conversation.
I'll just chip in and say that Michal Migurski is *absolutely right*.

From what you have written so far, I am not able to see a need that
cannot be solved using PHP and the JSON library. If you can express
your need more clearly, I am certain we can find a way to fulfill it.

(On the other hand, the "sample data for a C# parser" does have an
error. It should not end with a semicolon).
Lasse Reichstein Nielsen  -  lrn@hotpop.com
 DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html
  'Faith without judgement merely degrades the spirit divine.'

Site Timeline