Square | Phonic | Convert JSON to Map

Give below astring, which is similar to json, with multiple layers. Each next level will have two more empty spaces than the previous level.

 K1:V1
 K2:V2
 K3:
   K31:V31
   K32:
     K321:V321
      K322:V322
    K33:V33
 K4:
   K41:V41
   K42:V42"

we need to build a data structure.
get(k1) returns v1
get(k2) returns v2
get(k3)(k31) returns v31.
Any idea how to do this?

Comments (14)