Added functionality to writeJson