nlib
nn::nlib::msgpack::JsonPatch Class Reference

Class to apply JSON Patch (RFC-6902). More...

#include "nn/nlib/msgpack/JsonPatch.h"

Static Public Member Functions

static errno_t Apply (MpObject *obj, MpObject *patch, size_t *index) noexcept
 Applies JSON Patch. If it fails, obj is restored to the state before this function was executed. More...
 

Detailed Description

Class to apply JSON Patch (RFC-6902).

Description
Applies a JSON Patch document constructed using JsonPatchBuilder or a similar method.
See also
https://tools.ietf.org/html/rfc6902
https://triple-underscore.github.io/RFC6902-ja.html

Definition at line 70 of file JsonPatch.h.

Member Function Documentation

◆ Apply()

nn::nlib::msgpack::JsonPatch::Apply ( MpObject obj,
MpObject patch,
size_t *  index 
)
staticnoexcept

Applies JSON Patch. If it fails, obj is restored to the state before this function was executed.

Parameters
[in]objMpObject that corresponds to JSON that JSON Patch is applied to.
[in]patchMpObject that corresponds to JSON Patch.
[in]indexWhen not NULL, contains the index that points the location where JSON Patch has failed to be applied if that failure has occurred.
Return values
0Success.
EINVALIndicates that obj or patch was NULL, patch was not an array or no required key was specified, or no valid operation was specified in the "op" key.
ENOMEMIndicates that the memory allocation failed.
EPERMIndicates that the test operation failed.
ENOENTIndicates that the location required in obj was not available in obj.
EILSEQIndicates that a syntax error was found in the specified JSON Pointer.
Description
Applies the JSON Patch operations described in patch in order. Returns 0 if all the operations have successfully completed or another value if any of them has failed. If any of the operations has failed, the portion corresponding to that operation is stored in index (zero-based) and JSON for obj is restored to the state before this function was executed. Note that patch is destroyed regardless of whether or not this function has successfully completed.

The documentation for this class was generated from the following files: