[x3d-public] impact for JSON: ES6 and duplicate object literal properties

Don Brutzman brutzman at nps.edu
Mon Dec 19 12:25:59 PST 2016


On 12/19/2016 10:47 AM, Yves Piguet wrote:
> ECMAScript 2015 is very clear about what it considers as valid JSON; see http://www.ecma-international.org/ecma-262/6.0/#sec-24.3.1.1
>
>> It is not permitted for a conforming implementation of JSON.parse to extend the JSON grammars. If an implementation wishes to support a modified or extended JSON interchange format it must do so by defining a different parse function.

understood, makes sense.

am flagging the following NOTE as coming from the spec:

>> NOTE In the case where there are duplicate name Strings within an object, lexically preceding values for the same key shall be overwritten
>
> Multiple fields with the same key are valid in JSON, but useless: you must not preserve them upon input.
>
> Now one might want to disregard the ECMAScript JSON.parse way of reading JSON, but imo that would be a bad choice.
>
> Yves

Sounds good.

I was just looking around the encoding specifications; i thought we had words for this to only use first occurrence in VRML encodings, but not finding them.

*Inventory of X3D specifications on name-uniqueness issues*

a. abstract spec, SAI: not mentioned since it is self-contradicting and an error condition, which at most typically says "behavior undefined" for errors.

b. XML encoding: not possible for simple types since duplicate attributes fail XML validation; SFNode/MFNode fields based on DTD/Schema so duplicated SFNode is typically flagged as an error.  Schematron provides additional edge-case checks.

c. VRML97/ClassicVRML encodings- not found.  TODO needed since the grammar won't catch this error.  Specification comments submitted.

d. X3D Compressed Binary Encoding (CBE) - not possible since based on XML encoding.

e. X3D EXI-based Efficient Binary Encoding (work in progress) - not possible since based on XML encoding.

f. X3D JSON encoding: TODO we should add explicit wording to draft specification that lists duplicate fields as erroneous.

g. X3D Object Model (work in progress) - TODO note neither possible or legal.

h. X3D ECMAscript and Java language bindings: not possible since Script node does not allow duplicate field definitions.
	29.4.1 Script
	http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/scripting.html#Script
	"The type can be any of the standard X3D fields (as defined in 5 Field type reference). Name shall be an identifier that is unique for this Script node."

i. Prototype declarations: field uniqueness requirement not found.  Specification comment submitted.
	4.4.4.2 PROTO interface declaration semantics
	http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/concepts.html#PROTOinterfacedeclsemantics

j. Inline IMPORT/EXPORT: Most uniqueness is handled when exposing DEF names.  TODO we should be stricter in noting that alias AS names must also meet uniqueness requirements in the local DEF namespace.

	4.4.6 Import/Export semantics
	http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/concepts.html#ImportExportsemantics

	9.2.5 IMPORT statement
	http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/networking.html#IMPORTStatement

	9.2.6 EXPORT statement
	http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/networking.html#EXPORTStatement



>> On 19 Dec 2016, at 18:58, <yottzumm at gmail.com> <yottzumm at gmail.com> wrote:
>>
>> On Dec 19, 2016 12:03 PM, "Don Brutzman" <brutzman at nps.edu> wrote:
>> Hmmm, maybe OK?  Here are some tests.
>> Maybe.   I'd like to put "use strict"; in front of it and run it through some browsers but I've been giving my hands a break.
>>
>> Codepen.io reports an error in chrome.
>>
>> 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
>>
>> There are two mentions of “object literal” in standard and they appear unrelated.  It’s mentioned under “Duplicate Object Literal Properties” on page 75 of Understanding ECMAScript 6:
>>
>>                 “But in ECMAScript 6, the duplicate property check was removed. Strict and non-strict mode code no longer check for duplicate properties.”
>>
>> I think maybe it’s just that the JSON parsers don’t catch it.

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