For the layout, you can use the built in circle packing layout as you suggest.
For formating the data to use it in this layout, you can use the d3.nest()
function. If you want some more insight on how nest works, then I suggest you to have a look at the following question: D3 JSON data conversion