RE: How to (not) clean JSON file in C#

RE: How to (not) clean JSON file in C#

RE:

It is not a surprise that I received again at the first interview stage, just for another company, the same puzzle with JSON cleaning. This time I had a clue about how to start and I could provide a solution to it in a reasonable time. I recommend reading first this article.

Puzzle statement

image.png

The solution

image.png

Final notes

Take it as a starting point and not as a recommended approach. It is far from a perfect solution, but it works at least for the examples provided. Creating a text parser can be a very complex task and requires a lot of test cases to cover and test. This is the main reason why I didn't like the puzzle: the statement was quite generic and did not have enough test cases so I had to make a lot of assumptions. Garbage in, garbage out, haha.

I hope can help some folks.

If you had to solve the same puzzle for an interview, please let me know about your approach and opinions on it. Cheers!