Created
June 29, 2012 21:16
-
-
Save andrewsardone/3020696 to your computer and use it in GitHub Desktop.
org.json.JSONObject halp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void testJSONObjectEquality() throws Exception { | |
final JSONObject json1 = new JSONObject("{ \"foo\" : 1 }"); | |
final JSONObject json2 = new JSONObject("{ \"foo\" : 1 }"); | |
assertEquals(json1, json2); | |
} | |
// junit.framework.AssertionFailedError: expected:<{"foo":1}> but was:<{"foo":1}> | |
public void testJSONObjectStringEquality() throws Exception { | |
final JSONObject json1 = new JSONObject("{ \"foo\" : 1 }"); | |
final JSONObject json2 = new JSONObject("{ \"foo\" : 1 }"); | |
assertEquals(json1.toString(), json2.toString()); | |
} | |
// Passes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JSONObject doesn't implement
Object.equals()
. Lame.