directory
Version:
v0.2.23
Opens a new window with list of versions in this module.
Published: Jun 4, 2026
License: MIT
Opens a new window with license information.
README
¶
Examples
Examples for the JSON Merge Patch (RFC 7386) implementation.
Quick Start
Choose an example to run:
go run ./examples/struct-merge
go run ./examples/map-merge
go run ./examples/json-string-merge
go run ./examples/json-bytes-merge
Example Structure
Each directory focuses on one document form:
struct-merge — type-safe struct operations
map-merge — dynamic map data operations
json-string-merge — JSON string processing
json-bytes-merge — JSON byte processing
Core Concepts
RFC 7386 Key Behaviors
- Recursive object merging — nested objects are merged recursively.
null deletes fields — null values remove target fields.
- Array replacement — arrays are replaced entirely, not element by element.
- New field addition — new fields from the patch are added to the target.
Supported Document Types
struct — type-safe documents converted through JSON
map[string]any — dynamic object form
string — valid JSON strings or raw string scalar values
[]byte — valid JSON byte slices
Directories
¶
Package main demonstrates byte-slice JSON Merge Patch usage.
|
Package main demonstrates byte-slice JSON Merge Patch usage. |
Package main demonstrates string-based JSON Merge Patch usage.
|
Package main demonstrates string-based JSON Merge Patch usage. |
Package main demonstrates map-based JSON Merge Patch usage.
|
Package main demonstrates map-based JSON Merge Patch usage. |
Package main demonstrates struct-based JSON Merge Patch usage.
|
Package main demonstrates struct-based JSON Merge Patch usage. |
Click to show internal directories.
Click to hide internal directories.