3 ms·
"you should be careful to know that Object Literals are not JSON." This rule is not only ridiculously pedantic, but the explanation page is twisted to the poin
by Dylan16807 14y ago
"you should be careful to know that Object Literals are not JSON."
This rule is not only ridiculously pedantic, but the explanation page is twisted to the point of stupidity. An object literal is the source code that compiles/executes directly to an object. JSON is very much an object literal. The runtime element that isn't the same as JSON text is simply called an 'object'. On top of that, the term "JSON Object" has no predefined meaning and using it to mean an object that was created via JSON is perfectly reasonable.
- k3n 14y agoGlad that I'm not alone in this. Though I'm no stranger to pedantry, this one is just being pedantic for pedantic's sake and really has no value, unless you really don't understand what JSON is....a string representation of a data-structure. I think we'd be in a better place if instead of `JSON.parse()` and `JSON.stringify()`, we had something a little more familiar such as `JSON.serialize()` and `JSON.unserialize()` for example. In a perfect world we'd simply override `Object.toString()`, because that's really what it is -- and I've never really used `toString()` for anything else on an object, especially not now with to prevalence of robust debuggers. But I digress...
- randuser 14y agoIf you learned about JSON without really knowing Javascript first, there might be confusement about what values are acceptable in object literals but not JSON.