Which lib can diff two dict tree?

esbatmop

Usenet Archive
Joined
Jul 19, 2012
Messages
1
Reaction score
0
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?
 

alex23

Usenet Archive
Joined
Jan 20, 2005
Messages
1,334
Reaction score
0
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

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,245
Members
248,133
Latest member
DujonT

Latest Threads

Top