Move parsing logic to json.c