<div dir="ltr">Thanks a lot, I got it.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 27, 2013 at 11:03 AM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve+comp.lang.python@pearwood.info" target="_blank">steve+comp.lang.python@pearwood.info</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Sun, 26 May 2013 21:32:40 -0700, Avnesh Shakya wrote:<br>
<br>
> But I want to compare line by line and value by value. but i found that<br>
> json data is unordered data, so how can i compare them without sorting<br>
> it. please give me some idea about it. I am new for it. I want to check<br>
> every value line by line.<br>
<br>
</div>Why do you care about checking every value line by line? As you say<br>
yourself, JSON data is unordered, so "line by line" is the wrong way to<br>
compare it.<br>
<br>
<br>
The right way is to decode the JSON data, and then compare whether it<br>
gives you the result you expect:<br>
<br>
a = json.load("file-a")<br>
b = json.load("file-b")<br>
if a == b:<br>
    print("file-a and file-b contain the same JSON data")<br>
<br>
If what you care about is the *data* stored in the JSON file, this is the<br>
correct way to check it.<br>
<br>
On the other hand, if you don't care about the data, but you want to<br>
detect changes to whitespace, blank lines, or other changes that make no<br>
difference to the JSON data, then there is no need to care that this is<br>
JSON data. Just treat it as text, and use the difflib library.<br>
<br>
<a href="http://docs.python.org/2/library/difflib.html" target="_blank">http://docs.python.org/2/library/difflib.html</a><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Steven<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div>