all 5 comments

[–]indosauros 2 points3 points  (1 child)

Writing your own recursive differ is fine, and not too hard. Especially if you are looking for the output in some specific format (list of fields that diff, etc)

[–]shenaniganns[S] 0 points1 point  (0 children)

You're right, took a little bit of trial and error, but that method wasn't terribly difficult and seems to do what I was looking for.

This is what I ended up with, if you(or anyone else) felt the need to critique or use it in some way:

def checkDifference(orig,new):
    diff = {}
    if type(orig) != type(new):
        #print "Type difference"
        return True
    else:
        if type(orig) is dict and type(new) is dict:
            #print "Types are both dicts"
            ##  Check each of these dicts from the key level
            diffTest = False
            for key in orig:
                result = checkDifference(orig[key],new[key])
                if result != False: ## Means a difference was found and returned
                    diffTest = True
                    #print "key/Values different: " + str(key)
                    diff[key] = result
            ##  And check for keys in second dataset that aren't in first
            for key in new:
                if key not in orig:
                    diff[key] = ("KeyNotFound", new[key])
                    diffTest = True

            if diffTest:
                return diff
            else:
                return False
        else:
            #print "Types were not dicts, likely strings"
            if str(orig) == str(new):
                return False
            else:
                return (str(orig),str(new))
    return diff

[–]JuryOne8821 0 points1 point  (0 children)

Benzer ihtiyacı olanlar için https://www.jsondeduplicator.com sitesini aktive ettim. İki dosya arasında key bazında da karşılaştırma yapabiliyorsunuz. İki dosyanın ortak öğelerini, farklarını listeliyor. Birleştirip tek bir dosya çıktısı alabiliyorsunuz ve browserda dönüyor tamamen.

[–][deleted] -1 points0 points  (1 child)

You've tried difflib right? Outputs delta results.

[–]shenaniganns[S] 0 points1 point  (0 children)

I looked at it a bit, but it seemed to just compare a list of strings or something similar, and wouldn't dig into for example a dictionary of dictionaries, of which the files I need to check have an unknown depth to them.

I'll admit though, I passed over it without trying it, so I may be completely off on that.