Smallest-Federated-Wiki icon indicating copy to clipboard operation
Smallest-Federated-Wiki copied to clipboard

Look at JSON-Patch to build the Journal

Open donpdonp opened this issue 12 years ago • 1 comments

http://tools.ietf.org/html/draft-ietf-appsawg-json-patch-03

A new standard is available to describe a set of changes to a JSON document. This seems useful for building the Journal part of a fedwiki document. The current journal understands one change, the 'edit' which replaces the entire paragraph. JSON Patch supports add, remove, move, copy, and replace.

There is a problem in that JSON Patch replaces pieces based on a unique key in the JSON document. The Story part of the fedwiki document is composed of hashes with identical keys ('type','id','text). JSON Patch uses a JSON Pointer which is only capable of specifying keys and not matching on values. It also supports using an index into an array.

To support JSON Patch, any part of the Story would need to know its index in the array. Or more drastically, the Story could change from an array to a hash of { "id-123":{"type":...,"text:...}, "id-abc"...}

I dont think the benefit is great enough to actually make such a change but I wanted to document that fact that it exists and has potential.

donpdonp avatar Sep 05 '12 16:09 donpdonp

I have now read the json-patch and corresponding json-pointer specs. Your suggestion makes complete sense now. Thank you.

Having story elements with duplicate ids is a problem waiting to happen. So far I have only seen problems when replaying the journal. Many actions are ambiguous in the presence of duplicate ids.

I'm thinking that ids that would be duplicates should be replaced with new, "alias" ids, generated on the fly. The original id could be saved as 'aka': '0948098234' which could be restored should the item move to a location where it is again unique. Algorithms that want to know the original identity of an item can examine item.aka || item.id.

I would like to see fields of a json object have similar size and lifetime. This is not the case now. However, should the server extract images from json and replace them with static asset references, then our most significant offender will be brought into line.

WardCunningham avatar Sep 21 '12 00:09 WardCunningham