Update map in loop

This will give a value of nil to "associated_products" if the product_id doesn’t exist in the associated_products map. Is that the behaviour you want? Are you looking to set another default value if that’s the case? Or do you only want to insert "associated_products" into order["products"][product_id] if associated_products[product_id] exists?