Add method to write JSON