On 6 juin 2013, at 15:45, Rick Waldron wrote:

On Thu, Jun 6, 2013 at 9:31 AM, Jeremy Darling 
<[email protected]<mailto:[email protected]>> wrote:
Copying in from another post I sent.  Instead of amending SHOULD to allow 
parsers to throw new errors why not have them emit collections when duplication 
is found?

Duplicate Keys should never have been allowed in the spec in the first place 
(most all key/value stores don't allow it) or if they were allowed when 
decomposed to JS objects they should have created arrays of values much like 
most frameworks do for duplicate keys in the HTTP headers.

Thus, and typing this makes my skin crawl and my head hurt:

{
  "myKey": "Value 1",
  "myKey": 2
}

Becomes, upon parse:

{
  "myKey": ["Value 1", 2]
}

All values have now been accounted for. nothing has been created or lost, and 
code that didn't take into account multiple keys but did type checking on 
values will fail or adapt gracefully.

This breaks extant data value invariants. Ignoring the original question and 
addressing only this example, let's say the expected value was a string (your 
example shows a string and a number)

  var parsed = JSON.parse(data);
  parsed.myKey.toUpperCase();
  // TypeError

This is web breaking.

Rick

I agree with Rick and would add that if myKey can legitimately be an array, 
with any type of elements, the receiver as no way to know what was the original 
message

In some cases, as to set an email "To" field, a JSON message can provide a 
string for an unique email or an array of emails. This is a very simple example 
which may be solved with regex analyses updates but:
- this may break existing implementations
- some more complex examples may not be detectable

[cid:[email protected]]
Alexandre Morgaut
Wakanda Community Manager
Email : [email protected]<mailto:[email protected]>
Web :   www.4D.com<http://www.4D.com>

4D SAS
60, rue d'Alsace
92110 Clichy - France
Standard :      +33 1 40 87 92 00




<<inline: ab50c5.png>>

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to