fix remaining outstanding errors
ensure memory is allocated for json object to avoid undefined behaviour leading to potential memory leaks