discomarathon / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

New JsonElements not equal #64

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. assertEquals(new JsonElement(), new JsonElement())
2. assertEquals(new JsonElement().hashCode(), new JsonElement().hashCode())
3. assertTrue(new JsonElement().equals(new JsonElement()))

What is the expected output? What do you see instead?
All these shoul dbe true, but they are false.

What version of the product are you using? On what operating system?
1.2.2

Please provide any additional information below.

Original issue reported on code.google.com by jacob.to...@gmail.com on 20 Oct 2008 at 7:37

GoogleCodeExporter commented 9 years ago
After r278 JsonNull elements created by Gson during deserialization are same 
elements. So, the reference equality will work for them.

Original comment by inder123 on 29 Oct 2008 at 11:34

GoogleCodeExporter commented 9 years ago
While it is nice to have equal method in JsonElement itself, it comes at a cost 
of a 
much more expensive value equality check instead of reference equality which is 
the 
default. Since we internally use collections to hold JsonElements, I would be 
concerned about the performance implications of implementing value equality. 
Can you 
give specific cases where this would be desirable? 

Original comment by inder123 on 29 Oct 2008 at 11:39

GoogleCodeExporter commented 9 years ago
I have lost track of the test case that was failing for me when I switched from
json-marshaller to google-gson.  I have sense worked around this. (I think by
comparing strings and not the objects).

The general use-case is when you are manual creating JsonObjects and you want to
compare them.

Original comment by jacob.to...@gmail.com on 31 Oct 2008 at 9:00

GoogleCodeExporter commented 9 years ago
FYI... The attached patch implements deep equals methods which addresses this 
issue.
 The patch also includes my escaping work because I was too lazy to cut it out.

Original comment by z13g...@gmail.com on 23 Apr 2009 at 9:00

Attachments:

GoogleCodeExporter commented 9 years ago
Deferred to a future release.

Original comment by inder123 on 29 Sep 2009 at 9:09

GoogleCodeExporter commented 9 years ago
This issue can probably be closed; JsonElement is abstract and cannot be 
instantiated.

Original comment by jessewil...@google.com on 20 Aug 2010 at 5:13

GoogleCodeExporter commented 9 years ago
... and actually it shouldn't be closed; the problem is that equals() and 
hashCode() aren't implemented for any of the JsonElement subtypes.

Original comment by limpbizkit on 3 Sep 2010 at 6:58

GoogleCodeExporter commented 9 years ago
Issue 225 has been merged into this issue.

Original comment by limpbizkit on 3 Sep 2010 at 6:58

GoogleCodeExporter commented 9 years ago

Original comment by inder123 on 1 Nov 2010 at 10:31

GoogleCodeExporter commented 9 years ago

Original comment by inder123 on 3 Nov 2010 at 12:28

GoogleCodeExporter commented 9 years ago

Original comment by inder123 on 3 Nov 2010 at 12:28

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r726.

Original comment by limpbizkit on 15 Feb 2011 at 12:14