Prev: Dynamically Creating Checkboxes
Next: Which is the best implementation of LISP family of languages for real world programming ?
From: Dominic on 10 Jun 2010 16:01 Hi there, I'm looking to transfer some data between functions and I thought I'd use json such that the notation will be like this: var myJSONThing = {12:34, 345:32, 987:345...}. function myFunction(myJSONThing){ .... } Now I looked and the name/value pair should, according to the documentation I could find, have the name enclosed with "s yet the script I'm writing seems to be working (at least in Firefox). Is it totally necessary to have the quotation marks or just good practice? Also, would it have an effect on iterating through the object? I guess the answer to the first of my questions is the important thing as I don't want it to break in the future. Cheers, Dom
From: Thomas 'PointedEars' Lahn on 10 Jun 2010 16:11 Dominic wrote: > I'm looking to transfer some data between functions and I thought I'd use > json such that the notation will be like this: > > var myJSONThing = {12:34, 345:32, 987:345...}. That is _not_ JSON. > function myFunction(myJSONThing){ > ... > } > > Now I looked and the name/value pair should, according to the > documentation I could find, have the name enclosed with "s yet It MUST if it is supposed to be JSON. > the script I'm writing seems to be working (at least in Firefox). Is it > totally necessary to have the quotation marks or just good practice? It is only necessary if you want JSON. You want to learn what JSON is, and what an ECMAScript-conforming (e.g., JavaScript) Object initializer/literal is instead: <http://json.org/> <http://jibbering.com/faq/#posting> PointedEars -- Danny Goodman's books are out of date and teach practices that are positively harmful for cross-browser scripting. -- Richard Cornford, cljs, <cife6q$253$1$8300dec7(a)news.demon.co.uk> (2004)
From: Garrett Smith on 10 Jun 2010 19:02 On 6/10/2010 1:11 PM, Thomas 'PointedEars' Lahn wrote: > Dominic wrote: > [...] > It is only necessary if you want JSON. You want to learn what JSON is, and > what an ECMAScript-conforming (e.g., JavaScript) Object initializer/literal > is instead: > > <http://json.org/> > <http://jibbering.com/faq/#posting> > Also check out Hallvords JSON test suite. http://my.opera.com/core/blog/2009/12/18/native-json-support-in-opera very informative at a glance -- you can easily see what fails and then go directly to the source code. Garrett
From: Dominic on 11 Jun 2010 12:33
"Garrett Smith" <dhtmlkitchen(a)gmail.com> wrote in message news:hurquf$av9$3(a)news.eternal-september.org... > On 6/10/2010 1:11 PM, Thomas 'PointedEars' Lahn wrote: >> Dominic wrote: >> > [...] > >> It is only necessary if you want JSON. You want to learn what JSON is, >> and >> what an ECMAScript-conforming (e.g., JavaScript) Object >> initializer/literal >> is instead: >> >> <http://json.org/> >> <http://jibbering.com/faq/#posting> >> > > Also check out Hallvords JSON test suite. > > http://my.opera.com/core/blog/2009/12/18/native-json-support-in-opera > > very informative at a glance -- you can easily see what fails and then go > directly to the source code. > > Garrett Thank you both. As I was unclear I asked here and I got the answer I expected, my script is now changed. Though I initially was creating the JSON object by evaluating a string that I made I then changed and created it as a native object once I was happy with using JSON ;-) Dom |