© 2024 InterSystems Corporation, Cambridge, MA. All rights reserved.Privacy & TermsGuaranteeSection 508Contest Terms
update module.xml description
An implementation of JSON-Patch in ObjectScript.
JSON-Patch (RFC6902) is a standard format that allows you to update a JSON document by sending the changes rather than the whole document.
JSON Patch plays well with the HTTP PATCH verb (method) and REST style programming.
With zpm :
USER>zpm
zpm:USER>install objectscript-json-patch
Use it with this call :
Do ##class(Grongier.JSON.Utils).Patch(tDoc,tPatch)
Where :
The result will be tDoc patched.
Set tDoc = { "foo": { "bar": "baz", "waldo": "fred" }, "qux": { "corge": "grault" }
Set tPatch = [
{
"op": "move",
"from": "/foo/waldo",
"path": "/qux/thud"
}
]Do ##class(Grongier.JSON.Utils).Patch(tDoc,tPatch)
zw tDoc.%ToJSON()
Result
{
"foo": {
"bar": "baz"
},
"qux": {
"corge": "grault",
"thud": "fred"
}
}
Natively from git :
do ##class(%UnitTest.Manager).DebugRunTestCase("","Test.Grongier.JSON.Utils",,)
With zpm :
USER>zpm
zpm:USER>module-action objectscript-json-patch test