Skip to content

Latest commit

 

History

History
12 lines (10 loc) · 391 Bytes

replacing_key_values.md

File metadata and controls

12 lines (10 loc) · 391 Bytes

#Replacing a Value in a Key-Value Pair of an Object

To replace the value of an existing key, we can use a transform expression consisting of copy-modify-return:

let $crew := { "Captain" : "Kirk" }
return 
  copy $temp := $crew
    modify replace value of json $temp.Captain with "Piccard"
  return $temp

A caveat of using replace is that a missing key raises an error.