Advent of Kotlin: Week 4

We've started this advent with JSON stringify. This week, we will do the opposite: JSON parsing.

The process of parsing is transforming a string with an object representing an objects in JSON format into a representation of this object. Here is an example:

assertEquals( JsonObject( "o" to JsonObject( "a" to JsonString("AAA"), "b" to JsonNumber(123.45), "c" to JsonBoolean(true), "d" to JsonBoolean(false), "e" to JsonNull, ) ), parseJson("""{"o":{"a":"AAA","b":123.45,"c":true,"d":false,"e":null}}""") )

In this exercise, you might find regex really useful. If you don't know it, this course might be useful.

Here you the definition of the JSON parse function:

Here is the JsonElement definition:

Here are unit tests:


I wish you the best of luck in this and future challenges and can't wait to see your solutions :)