Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Properties defined multiple times #2

Closed
cecilemuller opened this issue Oct 17, 2014 · 3 comments
Closed

Properties defined multiple times #2

cecilemuller opened this issue Oct 17, 2014 · 3 comments
Labels

Comments

@cecilemuller
Copy link
Member

A question from the X3D mailing-list referencing #1 :

Something that jumps out is when you say "How would you make a Group that contains a Shape, a Transform and another Shape ? It can't be the following because an Object can't define property Shape twice".

That is indeed a serious constraint, if it is indeed correct - that wasn't clear about Javascript. (got a reference?)

@cecilemuller
Copy link
Member Author

Consider this Javascript code:

var myobj = JSON.parse('{"value": 1, "value": 2, "value": 3}');

Values 1 and 2 are lost, only 3 remains (in all web browsers and even Node & Io.js).
Same thing with PHP, only 3 remains:

$myobj = json_decode('{"value": 1, "value": 2, "value": 3}');

Therefore if something needs multiple values, use an Array, do not duplicate keys.

@coderextreme
Copy link

How was this closed?

@cecilemuller
Copy link
Member Author

Oh sorry I didn't see your comment until now.

It was closed because using duplicated keys in objects is not an option (otherwise it would be up to debate), it's a technical constraint to be compatible with native parsers like Javascript's JSON.parse.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants