Skip to content

Demonstration of updating and keeping fields using the JSON Merge Patch

License

Notifications You must be signed in to change notification settings

yo1000/spring-json-merge-patch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring JSON Merge Patch demo

Demonstration of updating and keeping fields using the JSON Merge Patch.

Requirements

  • Java 21

How to run

./mvnw clean spring-boot:run

Demo

Step 1: See the initial data.

curl -XGET "http://localhost:8080/users/1"
{"id":1,"username":"alice","familyName":"Liddell","givenName":"Alice","age":7}

Step 2: Update age and delete familyName by JSON Patch Merge request.

curl -XPATCH -H"Content-type:application/merge-patch+json" http://localhost:8080/users/1 -d '{"age":17, "familyName":null}'
{"id":1,"username":"alice","familyName":null,"givenName":"Alice","age":17}

Step 3: See the updated data.

curl -XGET "http://localhost:8080/users/1"
{"id":1,"username":"alice","familyName":null,"givenName":"Alice","age":17}

About

Demonstration of updating and keeping fields using the JSON Merge Patch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages