check for key existence before adding to serialized output