Added code for writing Json