6 ms·
> Python, go, rust and other obscure or archaic languages struggle with json. I recommend using a modern language such as js/nodejs, as it is meant for the web
by vageli 7y ago
> Python, go, rust and other obscure or archaic languages struggle with json. I recommend using a modern language such as js/nodejs, as it is meant for the web - where json is king among formats.
In what ways are the languages you listed obscure or archaic?
- TylerE 7y agoThey don't have leftpad.
- vorticalbox 7y agoin js/node is is a valid object { hello: 'world' } in python its not valid json = { "hello": "world" } in python you also can't do json.hello like in js, it would be json['hello']
- jkern 7y agoI'm going to be generous and hope this is some really dry humor and not an actual comment
- aflag 7y agoI don't understand what you're saying {hello: 'world'} is not valid json and neither Python's nor javascript's json parser from the standard library parse that.
- coldtea 7y agoNone of those mean Python is "obscure or archaic" or "unfit for json" etc. Regarding what is a valid object, it's about syntax. Python has a different syntax than JS. That doesn't mean Python is worse because JS has {hello: 'world'}. In fact that's an inconsistency of JS that only holds for _some_ keys (basically, valid identifiers): if the key has a space or a dash or something, you need to quote it: {'hello-1': 'world'}. So Python is more consistent in having only one style of map literal. >in python you also can't do json.hello like in js, it would be json['hello'] Again, irrelevant. Python has a different syntax. Python also has tons of stuff you can't do in JS. Operator overloading for example, in python myObj + myOtherObj is a valid user defined operation. None of this means JS or Python is superior. Ans none of this has anything to do with JSON. If you mean that JSON seems to be a better fit for JS syntax, that's because it was designed to be closer to JS syntax. That said, it's not JS syntax. {foo: "bar"} is valid JS but not JSON. JSON also doesn't accept classes, closures, and tons of other things that can go in a JS object.
- TylerE 7y agoPlus, if you really want it Python has tons of hooks to make json.load return whatever sort of struct you want.
- ben509 7y agoOr you can let json.load do its thing and use a nice module like json-syntax[1] to convert it to well typed values and back. (Yup, plugging my library.) [1]: https://pypi.org/project/json-syntax/ https://pypi.org/project/json-syntax/
- EdwardDiego 7y ago> in js/node is is a valid object > { hello :'world' } In JSON, that's invalid, because the key must be quoted. Check the spec.
- Sharlin 7y agoI sincerely hope the GP is a troll. No matter, the comment's dead now.