[aerogear-dev] [sync] Diff libraries

Corinne Krych corinnekrych at gmail.com
Thu Feb 6 08:32:21 EST 2014


Hello Guys,

So in despair of finding an iOS version of a ‘diff-patch’ library for object comparison, I’ve started implementing one [1]. It is pretty much inspired by jsonndiffpatch JS lib and use the same delta legend [2]. I haven’t finished it yet, it is missing LCS implementation[3] (the most complex part tbh) and it will need several iterations for completion. 

I will use it in our sync-demo app [4] replacing the actual use of google-diff-patch-merge [5] as like summers stated it, comparison of stringified objects is not sufficient. 

The idea is to stay pluggable in the way we handle conflict. If the app is a chat or text document we’ll use [5] with text differences.

++
Corinne
[1] https://github.com/corinnekrych/aerogear-diff-patch-ios
[2] https://github.com/benjamine/JsonDiffPatch#delta-legend
[3] http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
[4] https://github.com/corinnekrych/aerogear-ios-cookbook/blob/sync.demo.recipe/Hobbies/Hobbies/AGBuddiesViewController.m#L157
[5] https://github.com/JanX2/google-diff-match-patch-Objective-C (cool stuff i’m part of contributors! ;) there is no simple pleasure.

On 05 Feb 2014, at 16:37, Corinne Krych <corinnekrych at gmail.com> wrote:

> 
> On 05 Feb 2014, at 16:04, Summers Pittman <supittma at redhat.com> wrote:
> 
>> 
>> 
>> On Wed 05 Feb 2014 09:41:05 AM EST, Corinne Krych wrote:
>>> Rather than a text diff i’d like something that compares data structure (JSON like) diff.
>>> I can use google diff by serialiazing to string but it’s a plain text diff rather than object diff. Guess you can patch the stringyfied object an then convert it back to json structure but less elegant and flexible than jsondiffpatch on object.
>> 
>> If you go this route you need to make sure that things like order of variables, order of items in an array/collection, etc always come out the same way.
>> 
>> Also you need to make sure your stringified / merged JSON is still valid JSON.
>> 
> 
> Exactly. I dont feel that’s the right route
> 
> 
>> You may be off using hashing of your objects and doing set comparisons. Unfortunately I do not know of a library which makes that "free".  I used that on the DevNexus demo.
> 
> Jsondiffpatch js does handle it nicely.
> Might be some similar libs in Java?
> 
>> 
>>> 
>>> ++
>>> Corinne
>>> On 05 Feb 2014, at 11:23, Christos Vasilakis <cvasilak at gmail.com> wrote:
>>> 
>>>> Hi Corinne,
>>>> 
>>>> i did came across the following diff-match lib[1] might be interested to digg more, as I have seen they all derive from google-diff
>>>> 
>>>> [1] https://github.com/inquisitiveSoft/DiffMatchPatch-ObjC   [+podspec]
>>>> 
>>>> 
>>>> 
>>>> On Wed, Feb 5, 2014 at 10:49 AM, Corinne Krych <corinnekrych at gmail.com> wrote:
>>>> Hello Ladies and Gentlemen,
>>>> 
>>>> I was looking for some diff/patch libraries to get differences between 2 objects (either json format of map/array format) ideally in iOS (withpodspec) or in C/C++. To plug into custom conflict management in you sync demo app. Like Luke did using jsondiffpatch in JS [1].
>>>> 
>>>> For comparing text there is google-diff-match-patch [2] lib that is implemented in several langagues and format (including iOS).
>>>> 
>>>> But i couldn’t find a jsondiff liek lib for iOS… I’m asking my favourite oracle (i.e.: the mailing list), see if i get more lucky.
>>>> 
>>>> ++
>>>> Corinne
>>>> [1] https://github.com/benjamine/JsonDiffPatch
>>>> [2] https://github.com/JanX2/google-diff-match-patch
>>>> _______________________________________________
>>>> aerogear-dev mailing list
>>>> aerogear-dev at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>>> 
>>>> _______________________________________________
>>>> aerogear-dev mailing list
>>>> aerogear-dev at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>> 
>>> 
>>> _______________________________________________
>>> aerogear-dev mailing list
>>> aerogear-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/aerogear-dev
> 




More information about the aerogear-dev mailing list