# [Retina], 53 bytes

This answer is based on my [Perl answer](https://codegolf.stackexchange.com/a/129142/55508), with the help of [Martin Ender](https://codegolf.stackexchange.com/users/8478/martin-ender) for the golfing with Retina.

<pre><code>m(`^ *
[
$
]
\s+
,&#32;
:`.+
[$&amp;]
*T`[]`{}
], .
;&#32;
^.|]$

</code></pre>

[Try it online!][TIO-j4jq25bq]

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.


[Retina]: https://github.com/m-ender/retina
[TIO-j4jq25bq]: https://tio.run/##ZVFLUsMwDN3rFF4EpkObjD7@yOQYZdemExYsWMAC2AHX4gBcLMh2pkzBM9FTJL3np@Tl4e3x@X75/oIR9vM4wvFqY7g8beaTu4EDdDDB8XULOwe387CFQ3c9wc3dfJjm90@Ydm6A0cFp@Jg6WPZzt1B0drgEsYcEXChIJWApK7hcMJVQponB@YI1lGlHADiQT0ntBQdOVJuWeU/Bej7knGqFmLVlMfmE1mPNPtSKpMxNIZBqAuhxQMkqSKsaig82a3XmIBLbtIQYNGHNMWJQlJYbMykWGeHgPXOlEmmgTE0maw6yWos@CeUmGZlImi1Gc2NrFDfI5r9R7fq2S18dqPdNxlbOGJsDUeOmdi2r7Stin8q141ekFfHcWbGP/zp0ye0F@JJzRv2r9osA9sPIMYCH8AM "Retina – Try It Online"