json: check for missing key before appending field