ApplyWorkflowJSONPatch

Workflow data tools, ActiveX, DLL

Description

Applies an atomic JSON Patch to a source document and returns the patched document

Syntax

ActiveX

Function PDFlib::ApplyWorkflowJSONPatch(SourceJSON As String, PatchJSON As String, Indent As Long, SortNames As Long) As String

DLL

const wchar_t* DLApplyWorkflowJSONPatch(int InstanceID, const wchar_t* SourceJSON, const wchar_t* PatchJSON, int Indent, int SortNames);
const char* DLApplyWorkflowJSONPatchA(int InstanceID, const char* SourceJSON, const char* PatchJSON, int Indent, int SortNames);

Parameters

InstanceIDLibrary instance returned by DLCreateLibrary
SourceJSONDocument to patch
PatchJSONJSON array of up to 10,000 operations named add, remove, replace, move, copy or test
Indent-1 writes compact JSON in the original member order; 0 through 16 writes formatted JSON with that many spaces per level and LF line breaks
SortNamesNonzero sorts object member names by UTF-16 code unit in formatted output; ignored when Indent is -1

Return values

Returns a borrowed string that stays valid until a later call on the same instance; copy it at once, using DLStringResultLength for the wide function or DLAnsiStringResultLength for the ANSI function. A successful empty result is a valid empty string. Nil means the input was rejected; call GetWorkflowToolsError for the reason. Removing the whole document returns an empty string

Remarks

The operations run on a private copy; when any operation fails, including a test, the function returns Nil, the reason names the operation number and no partial result is produced

Array add accepts - to append; moving a value into its own descendant fails

The ANSI function converts text using the instance's SetAnsiMode setting; use UTF-8 mode for non-ASCII data

ActiveX exposes this method on IPDFlibrary24; obtain it with CoPDFlibrary.CreateEditionTools24 or query the default interface of PDFlibAX 4.74 or later

All editions include these functions. Failed ActiveX calls return an empty string, 0 or Empty and record the reason for GetWorkflowToolsError. The C#, VB.NET and Visual C++ WorkflowTools examples in the DLL and ActiveX demo folders show a complete request, page plan and rollback workflow

See also

Workflow data tools · Virtual file registry · GetWorkflowToolsError