Skip to content

Instantly share code, notes, and snippets.

@andrewsardone
Created June 29, 2012 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewsardone/3020696 to your computer and use it in GitHub Desktop.
Save andrewsardone/3020696 to your computer and use it in GitHub Desktop.
org.json.JSONObject halp
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
@daveray
Copy link

daveray commented Jul 1, 2012

JSONObject doesn't implement Object.equals(). Lame.

@andrewsardone
Copy link
Author

lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment