4 ms·
Edit: After seeing the comments, I checked my REPL history, and the bad data was still there. luckily with the spaces displayed as \040. Turns out the offendin
by dec0dedab0de 5y ago
Edit: After seeing the comments, I checked my REPL history, and the bad data was still there. luckily with the spaces displayed as \040. Turns out the offending space was \240, which makes more sense. Please disregard this comment.
If you're curious, the problem stems from stuffing JSON in the description field of an external system to do our own tagging. Someone (me) must have copy/pasted from a screwy source. We were pulling out our hair trying to figure out what was wrong with it, and I just stuck it in the REPL, and saw the offending character was a space. Manually deleted the extra space and it was fine. A quick google showed space was part of the convention, and we were like "woah that's weird how did we never stumble across that before." I am embarrassed that I posted this now. My only excuse is that I just got over Covid, so I'm going with that :-).
This was my original comment:
After about a decade of using JSON I just discovered the hard way that you can only have one space after the colon between a key and value. Atleast with the python JSON library.
- pythonthecware 5y agoYeah python is not exactly a language for the web. I know fresh grads and inexperienced professors claim otherwise but its not.
- lcrz 5y agoWhat a dumb take.
- pythonthecware 5y agoSays she while having issues decoding json as of 2021.
- sebzim4500 5y agoI don't see any evidence that python has issues decoding json.
- Eikon 5y agoWhat is “a language for the web”?
- pythonthecware 5y agoAny language that decodes json without issue. I mean it’s _the_ data format of the web ain’t it?
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- valparaiso 5y agoLmao half of SV startups are on python
- tyingq 5y ago$ python -c 'import json,sys;print(json.dumps(json.loads(sys.argv[1])))' '{"a": "b"}' {"a": "b"} Maybe it's been fixed? That's Python 3.8.10. What version is it broken in?
- lcrz 5y agoPython 2.7.16 (default, May 8 2021, 11:48:02) >>> import json >>> json.loads('{"a" : "b" }') {u'a': u'b'}
- dec0dedab0de 5y agoIn case either of you check your threads page, it was just a stupid mistake on my part. See my edit. Thank you for correcting me.
- lifthrasiir 5y agoWhich version of Python and/or JSON library? Since Python's built-in `json` module was first introduced in 2.6 and I can't see any evidence of this bug throughout the relevant code (either pure Python or C implementations).
- dec0dedab0de 5y agoSee my edit, it was just a stupid mistake on my part. Thanks for pointing this out.