Fix the json outpout no to add a trailing ',\n' with the last element.