57

Today I came across a bad Python question (this is what it looked like at the time I found it) that has accumulated millions of views and thousands of upvotes over the years.

A summary of its problems:

  • It was titled "Parsing values from a JSON file?", which made it a gigantic click magnet. (First Google result for "python parse json" and similar queries)
  • The "JSON" data is actually invalid, but this isn't obvious at first glance.
  • The OP included a piece of code that - supposedly - parses the JSON and "prints all of it". This clearly isn't true, as the data isn't valid JSON, so in reality the code throws an Exception.
  • The OP asked "How can I parse the file and extract single values?", which is terribly unclear (what "single values" are they trying to extract?).

Long story short, this question could/should have been closed as unclear and/or no MCVE. Because it wasn't closed, it has attracted some low-quality answers - some answers correctly point out that the JSON isn't actually JSON, while others simply ignore this issue and show some generic code for parsing JSON in Python.

I'm unsure how to deal with this train wreck.

I don't believe there's much value in this question - "your JSON is invalid" isn't an answer that's useful for an awful lot of people. I've edited the title to something less click-magnet-y, in hopes of pushing the question off the #1 spot on Google. Given its immense popularity, though, I'm afraid that it'll continue to show up in people's Google searches and waste their time.

What should we do about this question?

12
  • 83
    "Why has this clickbait question got so many upvotes. You may be surprised!"
    – Raedwald
    Commented Mar 19, 2019 at 14:54
  • 4
    If you believe it should be closed, vote to close.
    – yivi
    Commented Mar 19, 2019 at 14:58
  • 1
    Leave it, it's only borderline a typo question (vote if you think it is), and has been a great target for dupe hammering. I don't think there are any new answers needed for this question now or in the future, so closure won't harm it's usefulness.
    – Kevin B
    Commented Mar 19, 2019 at 15:15
  • 33
    @KevinB I don't think it's been a great duplicate target at all. I feel bad for everyone who got their question closed as duplicate of this mess. (Unless they had the exact same problem with incorrect JSON, but that's unlikely...) This is not the kind of high-quality Q&A I'm here for.
    – Aran-Fey
    Commented Mar 19, 2019 at 16:21
  • 16
    @everyone who voted to close that question: Please post an answer explaining your rationale; don't just silently take action. None of the existing answers suggest the question should be closed. I posted this question to find out what the community thinks should be done, and the consensus (so far) seems to be "don't close it". A bunch of vigilantes silently doing the opposite of what we're currently agreeing on is, frankly, infuriating. If you're going to go against the consensus, explaining yourself is the least you can do. I'm tired of the comminity saying one thing and doing another.
    – Aran-Fey
    Commented Mar 19, 2019 at 18:23
  • 4
    In my opinion, " 'your JSON is invalid' isn't an answer that's useful for an awful lot of people," does not necessarily mesh with, "but this isn't obvious at first glance." Sometimes confirmation that you definitely have an issue with the data and just need to find it is useful for focusing your efforts.
    – jpmc26
    Commented Mar 19, 2019 at 20:52
  • 2
    I just want to let people know that almost everything in the question has been edited into its current state by the community. THIS is what the original question was: stackoverflow.com/revisions/2835559/1 Practically everything you see in the current question was community-created because the original, as you can see, was terrible in practically every way imaginable.
    – Nick Vitha
    Commented Mar 20, 2019 at 22:15
  • @NickVitha, Ho my . Can we just roll back an deleted everything? I mean Edit obviously change the question. Let's just pretend it never happends. Commented Mar 22, 2019 at 10:14
  • 1
    @xdtTransform That's why we have the edit function. There's nothing privileged about the original question: the goal is to have good quality Q&As and that can be done both by closing garbage, or transforming garbage into something useful.
    – divibisan
    Commented Mar 22, 2019 at 14:55
  • 1
    There used to be a time when you could copy paste "your JSON is not actually valid JSON" to answer almost any JSON question on SO and have a reasonable chance of being right. Of the 36 answers I have written with the json tag, seven are some (hopefully more informative) variation on "your JSON is not valid". I think this is a useful question and even if there are some low quality answers, the accepted one is great.
    – JeremyP
    Commented Mar 22, 2019 at 16:08
  • 1
    There was a new attempt in 2022. Commented Jul 7, 2022 at 14:04
  • FYI: it looks like the invalid JSON was the result of an attempt by OP to remove confidential information; thus he thinks the thing works because he runs it on the original file.
    – Joshua
    Commented Jul 14, 2022 at 23:38

5 Answers 5

38

The edit that you made is great. Sometimes great answers are the result of not-so-great questions and since it's the responsibility of the many to curate the content, the only thing to do at times is to make the question better align with the content we really want to keep (in this case, the answer).

We also have to do this when we merge many duplicates into one, which essentially copies a bunch of similar answers to the same canonical question. tl;dr;: Don't be shy with edits that are needed to save great content that might otherwise go out into the night.

The OP will be notified of the edit and if they don't wish to be associated with it any longer, they can contact us. But, well, I don't think that's going to be an issue in this case (after all, who throws away a winning lottery ticket :))

6
  • 1
    Is editing the title really all that should be done? I'm not happy about this bad question being left alone just because it has a good answer. Shouldn't the question be closed or at least edited in some way? Do the rules no longer apply once a good answer has been posted? We want to have high quality Q&A, and this question is the opposite of that.
    – Aran-Fey
    Commented Mar 19, 2019 at 16:52
  • 4
    @Aran-Fey If you see possible ways to improve it then great, but I don't think there's any immediate need. It's not unusual for people to not fully understand what they're asking; that's .. why they ask :) The new title encapsulates the endeavor, the malformed JSON doesn't seem out of place and that immediately leads to an answer that shows how it's done once the data is as expected. I think it's fine as it is, but if you see room to improve it that also preserves the original intent of the question, great.
    – user50049
    Commented Mar 19, 2019 at 17:08
  • 1
    Hmm, well this is a surprise. I thought there was no doubt that this question is close-worthy (in other words, not fine). But anyway, no, I don't see a way to fix this question (which is why I had to make a meta post about it). jpmc26's edit that added an error message was a step in the right direction, but the "How can I parse the file and extract single values?" thing is still unclear and don't know what to do about it. We could outright remove it, I guess? I don't know.
    – Aran-Fey
    Commented Mar 19, 2019 at 18:00
  • @Aran-Fey you could make an educated guess of what the actual question meant or simply remove the line such that it doesn't ask about that anymore and focus on the parsing json correctly in python.
    – Braiam
    Commented Mar 19, 2019 at 18:48
  • 2
    who throws away a winning lottery ticket :)) My dad. He also painted himself into a corner, cut the tree limb he was sitting on, reached into a running lawnmower, and could do math I can't even comprehend as solvable. To dad, the lottery ticket was just another sheet of paper, and something that shouldn't have been left on the kitchen table before dinner. Commented Mar 21, 2019 at 20:47
  • Imo, edit went to far on this one: stackoverflow.com/revisions/2835559/1. Since I started SO, Json tag looked like a major duplicate nest. I understand the need of cannonnical but this look to mutch to mee. Commented Mar 22, 2019 at 10:34
12

There's one major thing we should still edit in: the error message. This will make the question easier to find.

Waiting for some community opinion before I do so myself. It's done.

5
  • 2
    a now it is closed, should be reopened in my opinion
    – Vickel
    Commented Mar 19, 2019 at 17:45
  • @Vickel In its current form, if it should be closed it all, it would have to be as a dupe, imo.
    – jpmc26
    Commented Mar 19, 2019 at 20:50
  • 3
    I will admit I was skeptical about this suggestion at first, but after seeing the edited question I have to say it's actually an impressive transformation. With this and the new title, the question is now... tolerable. (It's still bad, but since it's no longer so very easy to stumble upon, I don't care as much.) I was initially considering closing and possibly even deleting the question, but none of that is necessary now. Nice work.
    – Aran-Fey
    Commented Mar 19, 2019 at 22:23
  • @Aran-Fey IMHO this question seemed to have helped a lot of people to understand the difference between lists and dictionaries, right? So I think it is useful. Anyway after re-opening its having a close vote again...
    – Vickel
    Commented Mar 19, 2019 at 22:26
  • 5
    @Aran-Fey I agree the question isn't stellar, but the problem is probably super common. A lot of people who are new to Python will probably run into it and be confused. And to be fair, if your JSON is complex, it's easy to miss the problem. For me, that's enough justification for it to exist.
    – jpmc26
    Commented Mar 19, 2019 at 22:31
6

If the question title is click bait, change the question title so it is not click bait.

1
  • Yes, that's taken care of. What about the question's other problems, though?
    – Aran-Fey
    Commented Mar 19, 2019 at 16:54
2

To all people viewing this meta question: this is how the JSON parsing question looked like before this meta question was asked, in its "terrible and misleading" form.

What should be done about this immensely popular but terrible and misleading question?

The same thing which is being done every day for countless other terrible and misleading questions being asked on StackOverflow: nothing.

Long story short, this question could/should have been closed as unclear and/or no MCVE.

No, this question has an accepted answer, which is as clear indication as it could be that the problem in the question was clear, reproducible and solvable, by at least one person. Now that some people decided to spend their time improving this question, it became much more clear and does have MCVE, so closing it would have been premature.

I don't believe there's much value in this question - "your JSON is invalid" isn't an answer that's useful for an awful lot of people.

To the contrary, as of now, there are 1348 upvotes from people who think that this questiton is useful. Probably there's an awful lot more people who did not vote, but still had the same problem, could not solve it themselves, came to StackOverflow and found an answer under this question.

Given its immense popularity, though, I'm afraid that it'll continue to show up in people's Google searches and waste their time.

In general, "popular" does not mean "good", it only means that a lot of people think it's good. I don't think that it's as big a problem as you imply in your question - people may waste their time in any way they like, it's their business, if you don't like it it's better to move on and spend your time on something that you think is important, not on optimizing other people's time (well, unless you are their direct manager, but it's entirely different story).

6
  • 2
    "there are 1348 upvotes from people who think that this questiton is useful" Correction: There are 1348 upvotes from people who came here from google, and upvoted the question without reading it because it helped them. If any of those upvotes are actually from people who think the question is good, then we need to stop pretending that SO is a high quality Q&A site and acknowledge that it's a garbage dump.
    – Aran-Fey
    Commented Mar 19, 2019 at 21:37
  • 3
    Yes it's a garbage dump, has been for a long time, but you still could dig a pearl or two if you sift through the garbage carefully...
    – artem
    Commented Mar 19, 2019 at 21:39
  • 7
    About your last point: I'm optimizing other people's time because I want SO to be a high quality knowledge repository. That's what I'm here for. If I see garbage, I clean it up, because I don't want it to waste anybody's time. Sorry, but if doing nothing is the correct course of action to take here, then I'll stop participating on SO.
    – Aran-Fey
    Commented Mar 19, 2019 at 21:46
  • There is no such thing as "correct course of action" here, everyone does what they think is best. If you think it makes sense to spend effort cleaning up this site up by any means do it. As for me, I see the "clean up all the garbage" task as insurmountable, and I'm OK with many many less-then-useful questions and answers in the otherwise "high quality knowledge repository".
    – artem
    Commented Mar 19, 2019 at 21:50
  • 7
    Well, it's undeniable that cleaning up all the garbage is impossible. Luckily most of it is rotting away in places where nobody sees it. But this is popular garbage. If we don't clean this up, why do we clean at all?
    – Aran-Fey
    Commented Mar 19, 2019 at 21:53
  • 5
    You did your part, some people agreed with you and closed that question. But then, in a short time (3 hours is really quick in close/open wars) there were enough people who disagreed and voted to reopen. Apparently, different people have different opinions on what's garbage and what's useful. Ideally, these two groups of people would not have shared the same web site, but that what the network effect does to people - having a single resource shared by everyone is so attractive that people are willing to accommodate varying standards of quality.
    – artem
    Commented Mar 19, 2019 at 22:10
-13

I simply don't understand why this question is getting a treatment like this.

The question is highly upvoted (1348) which means that a lot of SO users have found it useful.

The highest upvoted answer is at 2007 which means that a lot of SO users found it useful.

The question/answer is 10 years old and now a single meta-post causes multiple edits and close of the question. A few meta-users overrules what so many other users have had to say about the question. IMO that's ridicules.

A summary of its problems:

It was titled "Parsing values from a JSON file?", which made it a gigantic click magnet.

Not a problem. The question is about parsing a JSON file so the title is correct. That the title is a "gigantic click magnet" is perfectly fine. Good that SO is on top of search list.

The "JSON" data is actually invalid, but this isn't obvious at first glance

Not a problem. A good answer can simply explain that. Further, since it isn't obvious that it's invalid json, many users may benefit for learning about that non-obvious error. Maybe that's exactly what the voting shows.

The OP included a piece of code that - supposedly - parses the JSON and "prints all of it". This clearly isn't true, as the data isn't valid JSON, so in reality the code throws an Exception.

Not a problem. It's just the same as above... "your code doesn't work because your json file has a non-obvious error. The error is ..." would be a fine answer.

The OP asked "How can I parse the file and extract single values?", which is terribly unclear (what "single values" are they trying to extract?).

Can't see how that can be difficult to understand. OP want's to know how to access "maps" /"masks"/etc. and how to access what is inside "maps"/"masks"/etc. Both the accepted and other answers seem to address that so that was not "terribly unclear" to them either.

What should we do about this question?

Nothing- except perhaps reverting the edits caused by this meta.

2
  • 3
    Thanks for posting your point of view, but I have to say I disagree with all of it (no big surprise). The question is not about parsing JSON - it's about parsing incorrect json. Big difference. It's a terrible first google result, because it's relevant to virtually nobody. There are much better JSON questions out there. And, sadly, the number of upvotes is not a reliable indicator for quality. A lot of terrible answers have been massively upvoted by hordes of people who have no idea what they're doing. Those are "this helped me" upvotes, not "this is a good answer/question" upvotes.
    – Aran-Fey
    Commented Mar 19, 2019 at 21:30
  • 3
    Ignoring the fact that the code doesn't do what the OP claimed it does, there's still the problem that this question is actually asking 3 questions: 1) How to parse JSON? 2) How to parse this specific incorrect JSON? 3) How do access values in a nested dict/list structure. If that's not a terrible question, I don't know what is.
    – Aran-Fey
    Commented Mar 19, 2019 at 21:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .