Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

First off, there aren't really any benefits, other than it being simpler and more elegant. Right now you're going from Python Dictionary -> JSON-like-string -> JSON. There should be a way to go Python Dictionary -> JSON. It just seems like a code smell. Really though, if it ain't broke, don't worry about it. I was just curious as to why there was this roundabout.

Removing the quotes won't fix the problem, because you've also altered the way characters are escaped via the .replace() calls.

One potential downside of making it just straight JSON is that this is generated by our Python template and if for whatever reason this isn't valid JSON it would throw a javascript exception when the file is loaded.

I'm not familiar with Python, but there shouldn't be any reason why simplejson would return invalid JSON. In the event that it does, your script would still break, anyway. Granted, it won't be a javascript exception, but it would certainly fail elsewhere.

Like I said before, it really doesn't matter because it works :)



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: