Added JSON formatting function.