Skip to content

How to generate json-crdt-patch by comparing two POJO JSON objects? #504

Answered by streamich
VincentK-ZA asked this question in Q&A
Discussion options

You must be logged in to vote

My initial though was to use the above compare method from Fast-JSON-Patch to get an array of patches, and to then try and build the crdt-patch operations using the PatchBuilder, but I don't feel like this is the best approach.

There is already code which creates JSON CRDT Patch patches out of JSON Patch patches, see.

import {JsonPatch} from 'json-joy/es2020/json-crdt/json-patch';

const patcher = new JsonPatch(model);
patcher.apply(yourJsonPatch);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by streamich
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants