📋JSON Patch Copy Operation
Duplicate values within JSON documents
What is the Copy Operation?
The copy operation duplicates the value at the "from" path to the "path" location. Unlike move, the source value remains in place. This is useful for creating backups or duplicating data.
Syntax
Examples
Copy Property
Duplicate a value to a new location
Patch:
Before:
After:
Copy Nested Object
Duplicate an entire object structure
Patch:
Before:
After:
Copy Array Element
Duplicate an item within an array
Patch:
Before:
After:
Real World: Reuse the Billing Address
Default the shipping address to the billing one
Patch:
Before:
After:
Common Use Cases
- Creating backup copies before modifications
- Duplicating templates or configurations
- Copying shared values to multiple locations
- Creating variations based on existing data
Best Practices
- Creates a deep copy of the source value
- Source path must exist
- Useful for templates and default values
Copy Operation FAQ
Does copy link the two values?
No. copy makes a deep, independent clone - changing the copy later does not affect the source, and vice versa.
What is the difference between copy and move?
copy keeps the source value in place; move deletes it. Use copy for defaults and templates, move for renames and restructuring.
What happens if the destination already exists?
The destination follows add semantics: on an existing object key the value is replaced, and the destination parent must exist.
Try the Copy Operation Now
Use our free online JSON Patch generator to create copy patches instantly
🚀 Open JSON Patch Generator