Due to json's history does not support comments and its primary attended purpose as a interchange format. Personally the ability to comment a configuration file is really hannity and its sorely missed. Comment could be done by using something like JSON.minify() to removing all whitespace and comments before handing it over to JSON.parse(). Uber what add minify.json.js to thirdparty directory and then replace all JSON.parse() with JSON.parse(JSON.minify(str)) as a example. Thoughts? P.S. does anybody know which file containing JSON.parse()? P.P.S. TOML? Edit: - https://plus.google.com/ DouglasCrockfordEsq/posts/RK8qyGVaGSr
I don't think json should need many comments, use understandable identifiers. And if you really want comments you can do stuff like this: Code: { mystery: "qqqqBqq", mystery_comment: "in the property mystery q means stands for 'eat bbq in the morning' and B stands for 'eat bby in the afternoon' the string should have 7 letters, one for each of the days of the week, starting with monday" } I don't think it is a good idea to fidle with the json format. "We use json" is a straightforward thing that is easy to understand. "We use json, BUT..." is not. "We use <weird something called TOML whose specs apparently still change a lot>" is even worse imho.
@cola_colin Were not even using json for its a attended purpose. I really don't see how it is a problem to do this. If we were sending json fires to browsers. Not being able to comment config files is strange and I'd like to comment what I'm doing so people/future me know. Already thought of that but such a hack. What's wrong with documenting what you're doing? Now TOML its already being used in production and its designed for use as a config format. I am not saying Uber should change to it. IMHO its a better they json for what we are doing.
but ... json and javascript integrate SO DAMN GOOD. like wtf json just practically is javascript. Also how are we not using json for its puporse? The purpose is storing data and exchanging it. We do that.
Json is a subset of javascript (ECMAScript 3) and the only reason that comments our not in it is because Crockford said so. He didn't like what people were doing so he removed them. Json was designed to communication between a server and client which a config file is not.
json in the end is just "Hey look I put javascript objects in a file and put on a few more restrictions", I would not say it was "designed"
Code: { "somekey": "Some random text about this key, which goes after the comment and overwrites it because keys in JSON are unique per scope and only the last one is valid.", "somekey": true } or Code: { "comment": "This is a comment, but the key could be anything" } or use a YAML parser, which can read the JSON format with # for comments and doesn't choke on trailing commas,
The fact that is two standards around json show planning there were some designing going on. So yes "designed." E.g. removed comments form json
Or use a JSON pre-parser or parser they ignore comments. - http://tech.groups.yahoo.com/group/json/message/152 - section 4 of RFC 4627
Minify is a json pre-parser its supposed to go before a strict json parser. Doing it this way will allow people to comment out entire blocks of code or lines or document what's happening well PA is still running. doing this as a mod has one downside you still have to remove comments before releasing it. I'm willing to modding this but I don't know were json files are loaded into PA and subsequently give it to Uber to place into vanilla. True, although I'm not really sure what you by "PTE......ternal tools to update."
Anything that is currently parsing the game's json doesn't expect comments; therefore adding commented JSON would be a breaking change for those mods and tools. The PTE period would be to discover what breaks and make adjustments.
Minify removes all whitespace and comments before passing the json to the parser. I doubt they would be any breaking changes to mods and tools. Simply because the parser does not see comments but just to be safe PTE period anyway. Okay. - https://github.com/getify/JSON.minify - http://blog.getify.com/json-comments/
I was not a were of that; thank you for the clarification. So yes a PTE period would be required to fix any breaking changes in tools and mods.