473,657 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

json-php on slashdot

In my journal anyway:

"JSON: Javascript Unusable by the Client"

http://slashdot.org/~scriptify/journal/103074

Jul 23 '05 #1
9 1511
"George Jempty" <sc*******@yaho o.com> writes:
In my journal anyway:

"JSON: Javascript Unusable by the Client"

http://slashdot.org/~scriptify/journal/103074


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.
<URL:http://groups.yahoo.co m/group/json-php/message/9>

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).
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2
Lasse Reichstein Nielsen wrote:
"George Jempty" <sc*******@yaho o.com> writes:
In my journal anyway:

"JSON: Javascript Unusable by the Client"

http://slashdot.org/~scriptify/journal/103074
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.


JSON is nothing but an idea: there's no official specification. Mine
is nothing but an idea to possibly improve it. A viable and easily
implementable idea to fully accomodate all manner of client side
scripting. An idea to spark debate. To perhaps get enough momementum
behind JSON so that it becomes a specification.

Or to result in a fork. I've already got my acronym ready. Help me
stir up some controversy.

"When a true genius appears, you can know him by this sign: that all
the dunces are in a confederacy against him. -- Jonathan Swift"

Jul 23 '05 #3
On 5 Apr 2005 13:31:52 -0700, "George Jempty" <sc*******@yaho o.com>
wrote:
JSON is nothing but an idea: there's no official specification.
Definie "official"
Mine is nothing but an idea to possibly improve it.
but you've not made a proposal to improve it, you've made a load of
complaints against an implementation that isn't in anyway wrong, and
doesn't even stop you doing exactly what you want to do.
To perhaps get enough momementum
behind JSON so that it becomes a specification.
There's no standards body appropriate to take it - ECMA, there's no
point, too expensive, W3, not chartered to do anything in the area, a
member submission perhaps, but that would be the end of it, and we'd
need to dig up a member to submit it (or a 11,000 dollars to become a
member) but it doesn't need to go before a standards body or
consortium, it has a specification already.
Or to result in a fork. I've already got my acronym ready. Help me
stir up some controversy.


but there is no controversy, there's just your strange complaint
against an implementation which the developers seem to have addressed
well by my reading.

Jim.
Jul 23 '05 #4
Jim Ley wrote:
On 5 Apr 2005 13:31:52 -0700, "George Jempty" <sc*******@yaho o.com>
wrote:
JSON is nothing but an idea: there's no official specification.


Definie "official"
Mine is nothing but an idea to possibly improve it.


but you've not made a proposal to improve it


I most certainly have, and more than once; I suggest you re-read my
comments.

"The purpose of the Rule of Least Surprise is to reduce the amount of
complexity a user must absorb to use an interface." -- Eric S Raymond

Jul 23 '05 #5
"George Jempty" <sc*******@yaho o.com> writes:
JSON is nothing but an idea: there's no official specification.
Douglas Crockford's specification exists. Whether it is official
or not is a matter of definition.
Mine is nothing but an idea to possibly improve it.
My problem with your suggestion is that I don't see what problem it
solves, that doesn't already have a simpler solution (if you can
explain the problem so that I can see that I am wrong at this, please
do).

Instead it complicates the specification with extra fluff that is only
relevant to one single, very specific, use of JSON: in webpages read
by browsers and added to the page by a Javascript script element with
only the JSON expression as the script code.
A viable and easily implementable idea to fully accomodate all
manner of client side scripting.
No, not all manner of client side scripting.
*Webpage* in a *browser* using *Javascript* and loading the JSON
expression using a *script element* with a *src attribute*.

Any of these could be changed, and your addition has just become
an obstacle. And if everything matches, there is no problem
adding the assignment to the script without adding it to the JSON
syntax.
An idea to spark debate. To perhaps get enough momementum behind
JSON so that it becomes a specification.
Debate is raging. Your side is not doing too well at convincing the
other side :)

Momentum will come with use. One of the strengths of JSON is its
simplicity and generality, both of which your suggested addition
goes against.
Or to result in a fork. I've already got my acronym ready. Help me
stir up some controversy.


I don't see a need for controversy. It works perfectly well as
written. Again, if you can show a situation where it doesn't, I'd be
happy to see it.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #6
Lee
George Jempty said:

Jim Ley wrote:
On 5 Apr 2005 13:31:52 -0700, "George Jempty" <sc*******@yaho o.com>
wrote:
>JSON is nothing but an idea: there's no official specification.


Definie "official"
> Mine is nothing but an idea to possibly improve it.


but you've not made a proposal to improve it


I most certainly have, and more than once; I suggest you re-read my
comments.


So far, everybody who's read your comments seems to disagree with you.
JSON defines a format for values. You're asking for it to also include the
assignment of the value to a variable. That's not an improvement.

Jul 23 '05 #7
Lasse Reichstein Nielsen wrote:
"George Jempty" <sc*******@yaho o.com> writes:
JSON is nothing but an idea: there's no official specification.
Douglas Crockford's specification exists. Whether it is official
or not is a matter of definition.
Mine is nothing but an idea to possibly improve it.


My problem with your suggestion is that I don't see what problem it
solves, that doesn't already have a simpler solution (if you can
explain the problem so that I can see that I am wrong at this, please
do).

Instead it complicates the specification with extra fluff that is

only relevant to one single, very specific, use of JSON: in webpages read
by browsers and added to the page by a Javascript script element with
only the JSON expression as the script code.


And this one single very specific use of JSON is *precisely* the way
you would expect to be able to use it. The way Javascript has been
getting done *for ten years*. A way prescribed by the W3C for using
Javascript.

And the way I am going to use it, if I have to fork my own "standard"
and write my own parsers.

Jul 23 '05 #8
"George Jempty" <sc*******@yaho o.com> writes:
Lasse Reichstein Nielsen wrote: ....
one single, very specific, use of JSON: in webpages read
by browsers and added to the page by a Javascript script element with
only the JSON expression as the script code.


And this one single very specific use of JSON is *precisely* the way
you would expect to be able to use it.


No, not only that specific use, but also the additional requirement
that the script contents must
1) be static (if dynamically generated, e.g., with PHP, it's trivial
to add the assignment before the JSON value)
2) contain *only* a valid JSON expression (since otherwise, you could
just let it contain the assignment as well)
The way Javascript has been getting done *for ten years*. A way
prescribed by the W3C for using Javascript.
Then keep doing it. But your requirements are unnecessary. Drop the
second requirement above, and you don't need to change JSON's
syntax. If I have misinterpreted it, please tell me where I missed the
point.
And the way I am going to use it, if I have to fork my own "standard"
and write my own parsers.


Go right ahead, but I think there are easier ways to solve whatever
problem you are trying to solve.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #9
> And this one single very specific use of JSON is *precisely* the way
you would expect to be able to use it. The way Javascript has been
getting done *for ten years*. A way prescribed by the W3C for using
Javascript.

And the way I am going to use it, if I have to fork my own "standard"
and write my own parsers.


The usage pattern you have been describing is brittle and badly
factored. You certainly have a right to practice bad design, though I
don't understand why anyone would want to pay you to do so.

The changes you are proposing to JSON are unnecessary and will tend to
promote bad practices. Fork if you must, but I think you would do better
to understand the comments of the other people who have contributed to
this topic.

http://www.JSON.org
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
2686
by: G Matthew J | last post by:
http://htmatters.net/htm/1/2005/07/evaling-JSON.cfm This is more or less in response to Mr Crockford's admonition a few months ago, "fork if you must". Ironically, although in that usenet post he calls what I am suggesting "brittle", his own Javascript JSON parser is not valid JSON, but rather conforms to my proposed variation on JSON!! With an identifier prepended to the front of the JSON block, and function literals as values: see...
20
6845
by: Luke Matuszewski | last post by:
Welcome As suggested i looked into JSON project and was amazed but... What about cyclical data structures - anybody was faced it in some project ? Is there any satisactional recomendation... PS i am ready to use JSON as data/object interchange when using AJAX and my J2EE project - because it is easier to traverse the JavaScript object than its XML representation (so of course may argue).
8
10405
by: Douglas Crockford | last post by:
There is a new version of JSON.parse in JavaScript. It is vastly faster and smaller than the previous version. It uses a single call to eval to do the conversion, guarded by a single regexp test to assure that it is safe. JSON.parse = function (text) { return (/^(\s|]|"(\\|)*"|-?\d+(\.\d*)?(?\d+)?|true|false|null)+$/.test(text)) && eval('(' + text + ')'); };
2
3744
by: Kevin Newman | last post by:
Hello, I noticed that the JavaScript library for JSON posted on json.org (http://www.json.org/json.js) is modifying Object.prototype (adding a method - toJSONString). I thought this was considered bad practice because it can disrupt the use of for in loops on Objects. Am I incorrect? Thanks,
3
10170
by: Adam | last post by:
I'm trying to retrieve some values from a json object, but instead it's giving me the property name. For example: var json = { "glossary": { "title": "example glossary" } }; console.log(json); alert(json.glossary.title); for (var x in json) { console.log(x); alert(x.title); } This will show me the json object in the console with glossary and title underneath it. When the alert for json.glossary.title fires, it
2
3313
by: ChrisO | last post by:
I've been pretty infatuated with JSON for some time now since "discovering" it a while back. (It's been there all along in JavaScript, but it was just never "noticed" or used by most until recently -- or maybe I should just speak for myself.) The fact that JSON is more elegant goes without saying, yet I can't seem to find a way to use JSON the way I *really* want to use it: to create objects that can be instantated into multiple...
5
10571
by: Marc | last post by:
I'm aware that there are significant differences between VBScript objects and JScript objects but that doesn't mean something like the following should give me such troubles? <%@ Language=VBScript %> <script language="jscript" runat="server"> var json = {"widget":}; </script> <% Response.Write json.widget & "<br />"
23
3195
by: dhtmlkitchen | last post by:
JSON We all know what it is. In ECMAScript 4, there's a JSON proposal: Object.prototype.toJSONString String.prototype.parseJSON The current proposal, String.prototype.parseJSON, returns an object.
9
10866
by: Jon Paal [MSMD] | last post by:
using json like ( {"Records": , "RecordCount":"1" } ) and jquery like: $.ajax({ .... success: function(json, status) {
6
2819
by: Lasse Reichstein Nielsen | last post by:
Max <adsl@tiscali.itwrites: Not really. It shows that a particularly naïve implementation of a conversion from XML to JSON doesn't work well. What if the conversion of <e> some
0
8399
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8312
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6169
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4159
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.