1 of 3

Retina, 53 bytes

This answer is based on my Perl answer, with the help of Martin Ender for the golfing with Retina.

m(`^ *
[
$
]
\s+
, 
:`.+
[$&]
*T`[]`{}
], .
; 
^.|]$

Try it online!

The explanations can be found on my Perl answer. The differences are:

*
[
$
]

Instead of s/^ *(.+)/[$1]/gm to both remove the leading spaces and add brackets around the lines.

^.|]$

To remove the leading and trailing brackets for the third output.