Subject: [Json] Parsers

From: Jacob Davies <[email-masked]>
Date: Thu, 6 Jun 2013 10:19:10 -0700

RFC 4627 text:

4.  Parsers

   A JSON parser transforms a JSON text into another representation.  A
   JSON parser MUST accept all texts that conform to the JSON grammar.
   A JSON parser MAY accept non-JSON forms or extensions.

   An implementation may set limits on the size of texts that it
   accepts.  An implementation may set limits on the maximum depth of
   nesting.  An implementation may set limits on the range of numbers.
   An implementation may set limits on the length and character contents
   of strings.
--

1) It seems to me that "A JSON parser MUST accept all texts that
conform to the JSON grammar" is both impossible and immediately
contradicted in the next paragraph. No parser accepts all texts in the
sense of faithfully processing them into another representation
without error, because the entire text is of indefinite length, as are
many of its components, and

I think this is intending to say something about not inventing your
own subset of JSON. Maybe there is another way of expressing the
intent of this sentence.

2) I think there was also earlier discussion about whether the
acceptance of non-JSON forms or extensions is desirable. It seems
undesirable to me.

3) It is not stated that implementations may limit the number of
elements in arrays or objects. Perhaps that whole paragraph could be
something like: "Implementations may vary in their handling of the
size of texts, the maximum depth of nesting of arrays and objects, the
number of elements in arrays or objects, the range of numbers, and the
length and character contents of strings."

4) It might also suggest what parsers should do when they encounter
texts they cannot faithfully represent. Some extant implementations
truncate numbers larger than those they can faithfully represent, for
instance, which is bad. I think parsers should be strongly encouraged
to produce an error and no representation when they read a text they
cannot faithfully represent, rather than no error and a partial,
non-verisimilar representation.

-Jacob