Reputation: 658
My payload is below . This payload can have around 500 fields . But when user submit a save operation we are planning to have a standard patch operation. Trying to avoid sending a whole document when only a part has changed. How i can implement it in Mule ? Any design approach i can follow ? Any documentation or example . Please share the thoughts on how i can tackle in server side.
{
"loan": {
"loanId": 12345678,
"loanAmount": 100,
"processingStyle": "Standard",
"product": {
"prodId": "051",
"productDescrption": "Fixed"
},
"borrower": [
{
"borrower#": 1,
"borrowerFirstName": "ALICE"
},
{
"borrower#": 2,
"borrowerFirstName": "JOHN"
}
]
}
}
Patch operation JSON
[
{ "op": "replace", "path": "/loan/loanAmount", "value": "200" },
{ "op": "add", "path": "/product/productDescrption", "value": "Fixed" },
{ "op": "remove", "path": "/borrower/2" }
]
Upvotes: 0
Views: 247
Reputation: 4303
Depends on what your backend system is capable of , that would eventually be called by the Mule API - Maybe you can use a Java library that implements JSON Patch instead of taking care of the overhead yourself. Do give these a read.. https://apisyouwonthate.com/blog/put-vs-patch-vs-json-patch and https://sookocheff.com/post/api/understanding-json-patch/
Upvotes: 1