I need to create a shallow duplicate of a map inside my script, allowing me to change one of its keys afterwards. The spread operator provides one approach. But this runs inside a Jenkins pipeline, and our organization's policy disallows that operator.
Calling the clone() method succeeds, though Intellij reports "Access to 'clone' exceeds its access rights". This is partly due to the map having been created through Jenkins readJSON, which might supply a map-like object that doesn't implement the clone() method itself.
Which approach, excluding the spread operator, is most idiomatic for shallow map copying?