10 Comments
Jul 23, 2023Liked by John Crickett

This challenge was actually difficult but rewarding, I tried multiple times to write a fully fledged parser but I failed because I approached it in an unprincipled way. It took me 3 weeks to learn more about "Parser Combinators" from functional programming and apply that to this problem.

Finally I made it, if you're interested you can view my solution in Scala: https://github.com/Ghurtchu/build-your-own-X/tree/master/json-parser

P.S will add tests and a bit more functionality later, such as accepting input from file and so on.

Expand full comment
author

Glad to hear it was rewarding and that you learned from it.

Sounds like it would make a great blog post. Thanks for sharing the solution.

Expand full comment
Jul 23, 2023Liked by John Crickett

Absolutely! I was thinking the same, I think I'll write a blogpost and mention these challenges as well, thanks John!

Expand full comment
author

Cool, please let me know when you do and I'll share it on LinkedIn and Twitter.

Expand full comment

Hi John, I'm loving your posts, they are awesome. I will find some time to do all of them. Thanks for sharing it.

I would like to know what you think of doing a post like this for a yaml parser, I would love to read it it here.

I did one few months ago, but I'm eager to do it again following your steps.

- https://github.com/joaofveloso/java-vanilla/blob/main/src/main/java/com/vanilla/yamlParser/YamlParser.java

Expand full comment
author

Thanks. I've take a look into it.

Expand full comment

i have one doubt , can i use libraries for that , or from scratch ?

Expand full comment
author

If you use a JSON library what will you learn?

Expand full comment
Jun 24Liked by John Crickett

Means, can i use libraries like flex as a lexical analyser and something for parsing.. Like that?

Expand full comment
author

Yes, you can tackle the challenges at any level that allows you to learn.

You could do it both with a lexing and parsing library or without one or both.

Expand full comment