Diego Perini: > I have one question, without having gone through reading the specs. > > Would it be useful, and still spec compliant, to detect an "Invalid > leading comma" too as an error instead of a "Invalid property name" ? > > You already detect the "Invalid trailing comma" and the passed objects > could be generated dynamically, it would just improve the explicit > error in the eyes of the developer and pointing them to a less > deviating reason.
It is useful and I have already done it. <URL:http://asenbozhilov.com/json.html> [, 10, 20] -> Invalid leading comma {, "foo" : "bar"} -> Invalid leading comma But: {"foo" : "bar" ,, "baz" : "bar"} -> Invalid property name [10,,20] -> Illegal punctoator Does it make sense? Probably I have to change "Invalid property name" with more meaningful message: e.g. "Invalid token.type where expect string property name" ? Regarding trailing comma I added it explicitly because some major implementations allowed it in JSON string. See: <URL:http://asenbozhilov.com/json-parse.html> > This is just something that came up by trying to make your parser fail :) > > It is invaluable to have an independent JSON parser to test various > browsers implementations and at the same time test our own stuff. > > Thank you ! I am glad that you find it useful! -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
