Fix json parsing in api.c