Programmatically create json hierarchy

I got it.

I literally, copied the code below.
The input is a column from dataset with `completePath'.
Work like a charm.
Thank you for replying to my post quick.