But JSON specification said that string should use only double quote. And parameter name should use quotes for name too. For this input parser must return error at second character. I understand that this string is valid JSON object for JavaScript, but other languages and parsers is more strict, and will produce an error because bad syntax.
Last edit: modernskyangel 2013-02-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I agree that the strict application of the specification requires both properties and data to be quoted.
However many leading Javascript APIs (e.g. ExtJs/Sencha Touch) allow for a more relaxed interpretation of the specification.
For instance in Javascript the following is valid:
Formatter doesn't checks for syntax errors before formatting. I think you are trying to format a JS object defined in code here. I am thinking whether to fix it or not..
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others."
The plugin is meant for JSON data-interchange format not Javascript. The above thing is more of a job for a Javascript code formatter rather than a JSON Formatter. May be i should do a check for syntax errors before formatting(but that will make things too slow).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Single quotes should be treated in the same way as double quotes.
But JSON specification said that string should use only double quote. And parameter name should use quotes for name too. For this input parser must return error at second character. I understand that this string is valid JSON object for JavaScript, but other languages and parsers is more strict, and will produce an error because bad syntax.
Last edit: modernskyangel 2013-02-23
I agree that the strict application of the specification requires both properties and data to be quoted.
However many leading Javascript APIs (e.g. ExtJs/Sencha Touch) allow for a more relaxed interpretation of the specification.
For instance in Javascript the following is valid:
I have yet to find a formatter that works correctly with such applications.
It would be very nice if your plugin did! In fact I suspect that your plugin would become very popular!
Formatter doesn't checks for syntax errors before formatting. I think you are trying to format a JS object defined in code here. I am thinking whether to fix it or not..
Well, i just went through json.org
"JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others."
The plugin is meant for JSON data-interchange format not Javascript. The above thing is more of a job for a Javascript code formatter rather than a JSON Formatter. May be i should do a check for syntax errors before formatting(but that will make things too slow).
You have a good point: I should have been looking for a Javascript formatter plugin.
The JSMinNPP (http://jsminnpp.sourceforge.net/download.php) seems to be doing the job.