If print is given an array, it does already print it "complete", one item per line.
I suspect you are asking about way to recursively dump a structure, it's trivial to write such function - but take a look first, won't
formatJSON() do out-of-the-box what you need?