Background: I recently had a friend asked to write a JSON parser in a half-hour coding interview.
I was curious as to how quickly I could write one myself. The tl;dr is I don't think it's a reasonable interview question.
Caveats (abound):
- Do NOT EVER actually use this. I cannot express this enough.
- This is NOT code I'm proud of. I'm kind of embarassed by it but just wanted to see what I could do very quickly. Hell, it might be my worst code and I've done Advent of Code, so that's saying a lot!
- I was aiming for approx the same amount of code quality that I'd output in an hour-long coding interview.
- It still took me ~3-4 hours to get this written.
So the purpose was to gut-check whether it's reasonable to ask for a JSON-parser-from-scratch avoiding built-ins and IMO: No, it's not.
Anyone who conducts coding interviews should ask someone (or multiple someones!) who is currently working for them AT THAT LEVEL and use that to measure whether it's reasonable to ask for that in an interview.
Otherwise you're just wasting everyone's time to ask for something unreasonable, or you're just filtering for candidates who have seen Your Exact Problem Before (i.e. LeetCode B.S).