[x3d-public] impact for JSON: ES6 and duplicate object literal properties
Don Brutzman
brutzman at nps.edu
Mon Dec 19 09:03:25 PST 2016
Hmmm, maybe OK? Here are some tests.
On 12/18/2016 6:01 AM, yottzumm at gmail.com wrote:
> Note that in ES6, even in strict mode, the following will not cause an error:
>
> var books = {
> title: “Understanding ECMAScript 6”,
> title: “JavaScript: The Good, the Bad and the Ugly”
> };
>
> However,
>
> books.title === “JavaScript: The Good, the Bad and the Ugly”
Might you know the ES6 specification paragraph?
http://www.ecma-international.org/ecma-262/6.0/#sec-terms-and-definitions-object
Wondering why they might deviate from prior strictness in JSON object model - duplicate keys can't be represented as an object. Perhaps there is a site or online discussion that covers this?
> This will be important for JSON linters to catch, unless we want to do streaming JSON (we don’t).
how about jslint, jshint and X3DJSONLD ?
http://jsonlint.com
http://jshint.com
https://github.com/coderextreme/X3DJSONLD
I had trouble getting jsonlint or jshint to operate on your example, they balked mysteriously until replacing left-quote/right-quote characters. Also jslint failed silently under IE.
This strict version of your example works:
==============
{ "books":{
"title":"Understanding ECMAScript 6",
"title2":"JavaScript: The Good, the Bad and the Ugly"
}
}
==============
jslint and jshint report "duplicate key" for:
==============
{ "books":{
"title":"Understanding ECMAScript 6",
"title":"JavaScript: The Good, the Bad and the Ugly"
}
}
==============
if ES6 checkbox is selected, jslint still reports: Duplicate 'title'.
So maybe we are OK on this issue?
all the best, Don
--
Don Brutzman Naval Postgraduate School, Code USW/Br brutzman at nps.edu
Watkins 270, MOVES Institute, Monterey CA 93943-5000 USA +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman
More information about the x3d-public
mailing list