Fix json generation code. Now apparently generating correct data