Modified json api to fix encoding errors