# Pijul for application data sync

**URL:** <https://discourse.pijul.org/t/pijul-for-application-data-sync/741>\
**Category:** Question\
**Created:** [March 2, 2021, 9:57pm UTC](https://discourse.pijul.org/t/pijul-for-application-data-sync/741 "2021-03-02T21:57:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pjl](https://avatars.discourse-cdn.com/v4/letter/p/a8b319/32.png) [@pjl](https://discourse.pijul.org/u/pjl)\
**Post date:** [March 2, 2021, 9:57pm UTC](https://discourse.pijul.org/t/pijul-for-application-data-sync/741/1 "2021-03-02T21:57:19Z")

</div>

Currently afaik Pijul stores directories, text files, and maybe opaque binaries. I am wondering if it can be used for structured application data.

For example, currently I keep some app data in a json file, which naive text-based merging won’t do properly.

Is it possible to merge structured data with Pijul?

Like [GitHub - automerge/automerge: A JSON-like data structure (a CRDT) that can be modified concurrently by different users, and merged again automatically.](https://github.com/automerge/automerge).

---

<div class="post-metadata">

**Author:** ![pmeunier](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/pmeunier/32/4_2.png) [@pmeunier](https://discourse.pijul.org/u/pmeunier)\
**Post date:** [March 3, 2021, 6:44am UTC](https://discourse.pijul.org/t/pijul-for-application-data-sync/741/2 "2021-03-03T06:44:44Z")

</div>

Hi! First, automerge doesn’t handle conflicts, which is the central point of Pijul.

One could write a diff algorithm that splits the data into words instead of lines: this would already make JSON merging better (hopefully). Other than that, diffing trees is not an easy algorithmic problem.

---

<div class="post-metadata">

**Author:** ![fyr](https://avatars.discourse-cdn.com/v4/letter/f/b5ac83/32.png) [@fyr](https://discourse.pijul.org/u/fyr)\
**Post date:** [March 3, 2021, 11:31am UTC](https://discourse.pijul.org/t/pijul-for-application-data-sync/741/3 "2021-03-03T11:31:31Z")

</div>

For json you’d probably want a slightly more aggressive variant of git word-diff: instead of splitting on whitespace, you’d split on every transition between alphanumeric and non-alphanumeric characters.

Or put the “word” boundaries inside every bracket or brace and after(before?) every comma and colon, but that’s less general-purpose 😛

(And for well-behaved operations on trees in general, yeah at minimum you’d want to extent the pijul “x line is after y line” model to include “x line is child of y line, and comes before any line z that is after but _not_ a descendant of x”. Idk whether there are any indentation-based heuristics doing this sort of thing already.)
