Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old


Applies a patch to a json document.

Component Version macOS Windows Linux Server iOS SDK
JSON 14.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "JSON.JSONPatch.ApplyPatch"; json1; jsonPatch )   More


Parameter Description Example
json1 A JSON text or reference.
jsonPatch A JSON text or reference.


Returns JSON or error.


Applies a patch to a json document.
The jsonpatch functions implement the IETF standard JavaScript Object Notation (JSON) Patch.

The JSON Patch IETF standard requires that the JSON Patch method is atomic, so that if any JSON Patch operation results in an error, the target document is unchanged. The patch function implements this requirement by generating the inverse commands and building an undo stack, which is executed if any part of the patch fails.


Try it:

Let ( [
json1 = "{\"people\":[{\"first\":\"Christian\",\"last\":\"Miller\",\"city\":\"Nickenich\"}]}";
json2 = "{\"people\":[{\"first\":\"Peter\",\"city\":\"Nickenich\", \"zip\": 56645 }]}";
patch = MBS( "JSON.JSONPatch.FromDiff"; json1; json2 );
json3 = MBS( "JSON.JSONPatch.ApplyPatch"; json1; patch )
]; json1 & ¶ & ¶ & patch & ¶ & ¶ & json3 )

Example result:
{"people":[{"first":"Christian","last":"Miller","city":"Nickenich"}]} [ { "op": "replace", "path": "/people/0/first", "value": "Peter" }, { "op": "remove", "path": "/people/0/last" }, { "op": "add", "path": "/people/0/zip", "value": 56645 } ] { "people": [ { "first": "Peter", "city": "Nickenich", "zip": 56645 } ] }

See also

Release notes

Blog Entries

This function checks for a license.

Created 23th November 2023, last changed 23th November 2023

JSON.IsValid - JSON.JSONPatch.FromDiff