- Jan 4, 2006I agree 100% with you.
Anything the JS parser allows is considered valid:
- Quoted/Unquoted keys
- Numbered Keys
- Single/Double Quotes
- Scientific Notation
It is up to the coder to define 'best practices' not the format to
impose or restrict them.
common denominator to be compatible with other languages.
If your target are web apps, HTML and JS, just go and use the whole
set and more.
Crockford knows I always opposed his stubbornness ;-)
--- In email@example.com, Martin Cooper <mfncooper@g...> wrote:
> On 1/3/06, Douglas Crockford <douglas@c...> wrote:
> > JSON has a string notation which is similar to that used in the C
> > family languages. Strings are bounded by double quote characters.
> > Escapement is provided by the backslash. The spec specifically allows
> > the slash to be escaped so that JSON can be delivered in HTML
> These statements have me really wondering about what JSON is
supposed to be.
> The reasoning behind removing comments was that it would "more
> JSON with YAML and Python". Now we have double quoted strings only,
> "similar to that used in the C family language", and so that it "can be
> delivered in HTML documents".
> respect, it's beginning to seem like JSON is supposed to be a minimalist
> languages as possible. Perhaps it should be renamed "MON" for
> Notation? ;-) The "JSON" moniker is seeming less and less appropriate.
> The single quote convention is not included in JSON because it is not
> > needed.
> included it. It's convenient because it frequently allows you to avoid
> backslashes / escapes in string literals.
> All strings can be represented with the double quote notation.
> > C itself does not have single quote strings. Many PHP programmers are
> to... (... and add PHP programmers to my list of not-so-smart-folks
> can't understand string quoting... ;)
> JSON requires that keys be quoted because of an error in the
> > ECMAScript spec that disallows the use of unquoted reserved words as
> > keys. The list of reserved words is surprisingly long and difficult to
> > remember. The best practice is to always quote keys.
> That is a good reason to document a "best practice". It is in no way a
> reason to ban people from using unquoted key names.
> As an historical note, the very first JSON message contained as one of
> > its keys the word "do". It was not quoted, and it caused a syntax
> Not a good start, huh? ;-)
> Martin Cooper
> Yahoo! Groups Links
> [Non-text portions of this message have been removed]
- << Previous post in topic Next post in topic >>