6 ms·
Well, that completely misses the point of JSON: simple and unambiguous syntax. If you want something that's easier to edit for config files, you can use YAML.
by pdw 12y ago
Well, that completely misses the point of JSON: simple and unambiguous syntax.
If you want something that's easier to edit for config files, you can use YAML.
- zobzu 12y agoHJSON seems a lot simpler and closer to JSON than YAML. And.. yeah, for human processing/reading/writing, ignoring trailing commas and having comment does improve JSON IMO. I don't know why JSON is so strict in fact. Virtually everyone forgets to NOT have the last comma of a list all the time. Now then again HJSON is +1 standard and incompatible with JSON so im not sure how that'll take off.
- ngcazz 12y agoBut YAML is a superset of JSON.
- iLoch 12y agoI don't know about your comma statement. I never have a problem writing symantically correct JSON by hand - though there are limited use cases where you should need to do so anyway. If your IDE isn't marking invalid JSON syntax you need a better IDE.
- zobzu 12y agoI dont think syntax highlighting should excuse an unnecessarily complex syntax
- philjackson 12y agoIt doesn't really miss the point - the point was a more human friendly JSON and it hit that nail on the head pretty well if you ask me.
- dangerlibrary 12y ago"a more human friendly JSON" is a goal that misses the point of JSON.
- captainmuon 12y agoYes, exactly. But it's not even meant to replace JSON. It's not for exchanging data between computers, and its not for webservices etc. Its for when you need a quick config file, and you think "Gosh, I wish I could just put some sloppy JSON/Python-like code in here, with a few comments.", and you don't want to use XML, INI, or YAML, or roll your own format. I guess most people here are in the web development business. Which is fine, but I am not currently. I don't need JSON for what JSON is made for, but I often need something almost like JSON for my use cases.
- angersock 12y agoJust use JSON, and add a key (which you can ignore!) for comments. Even better, you get to use any of the dozens of already-tested JSON parsers out there for this! There is absolutely no reason you need to reinvent the wheel here. You know what's annoying? Having to remember a dozen-odd JSON-but-not-really config file syntaxes instead of just JSON.
- captainmuon 12y ago> You know what's annoying? Having to remember a dozen-odd JSON-but-not-really config file syntaxes instead of just JSON. That's why YAML is out of the question for me. But JSON is too restricted to write it manually (no trailing commas, no comments, no round-trip-safety). What I'd ideally like is to take this Python/JS5 file (differ only in the comment indicator # vs //) # this is an important comment obj = {'hello': 'world', 'list': [1,2,3,4,5,]} ... from configfile import obj and to turn it into a safe // this is an important comment {'hello': 'world', 'list': [1,2,3,4,5,]} ... obj = parser.loads("configfile.cfg") It's not that I don't like JSON. Its just that I have a different requirements. When I need JSON, I use JSON. When I need easily editable config files that look like Python or JS (which I can easily remember), I use something like HJSON.
- vlunkr 12y agoThat was my thought as I read this. Why repurpose JSON when YAML was written specifically for cases like this?
- Erwin 12y agoYAML has an enormous amount of odd features that go beyond simple data types, similar to XML (still seeing XXE here and there). I like the idea of a slightly simpler JSON but still keeping just the primitive data types yet not being able to say, include arbitrary files into the document.
- clarkevans 12y agoYAML could/should be given a haircut.
- mst 12y agoingy and I called that JSONY - see http://p3rl.org/JSONY http://p3rl.org/JSONY - written using Pegex to make it easy to port to other languages.
- dazmax 12y agoThink of this as an alternative to YAML for people who deal with a lot of JSON and don't want to always be switching back and forth between JSON and YAML (or toml or edn or whatever) with all the cognitive friction that can cause. They just want to be able to write sloppy JSON and have code handle all the strict requirements of real JSON.
- ape4 12y agoBut nobody does eval(json) anymore. Not safe. We use a special function. So could have a special function for this.
- wmil 12y agoYAML was ruined by whatever committee controls the standard. Thanks to extra features, that were implemented by most parsers, it's not safe to parse an untrusted document. Some people are pushing for TOML as an alternative but I'm not sure if that's going to happen.