Write data in JSON format