improve JSON rendering performance

I made a stupid mistake in the original implementation where I pretty much recreated a variable I had by looping over that variable. Don't ask.

I also updated the format of the JSON to be less data with the docs being updated to reflect that.

Some code comments were altered/improved too.