Which lib can diff two dict tree?

E

esbatmop

Q1:
dict a:{'a1': 'b1', 'a2': {'b2': 'c2'}, 'a3': 'b3'}
dict b:{'a1': 'b1', 'a2': {'b2': 'c3'}}
which lib can diff two dict tree?
like:
print struct_diff(a,b)
Q2
How can I diff two json file?How can I get struct_diff and value_diff?

Q3
How can I diff two xml file? How can I get struct_diff and value_diff?
 
A

alex23

Q1:
which lib can diff two dict tree?
Q2
How can I diff two json file?How can I get struct_diff and value_diff?
Q3
How can I diff two xml file? How can I get struct_diff and value_diff?

Rather than trying to come up with a method for finding the diffs of
three different data structures, it might be easier to transform all
the structures into the same form and then just use one mechanism for
diffs.

There's a 3rd-party python library for producing diffs of XML
documents:
http://www.logilab.org/projects/xmldiff

Python dicts can be converted to XML using one of the suggestions
here:
http://stackoverflow.com/questions/1019895/serialize-python-dictionary-to-xml

JSON can be transformed into dicts by using the standard library's
json module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top