Last active
July 5, 2016 15:00
-
-
Save takaki/d32d6fc359d640c300ff6f540fabc426 to your computer and use it in GitHub Desktop.
JavaでJSONを比較する ref: http://qiita.com/takaki@github/items/d61805e5a886f094bd1c
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
dependencies { | |
// https://mvnrepository.com/artifact/org.json/json | |
compile group: 'org.json', name: 'json', version: '20160212' | |
} |
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
{"bb":{"e":"あ"},"a":"hoge","b":"bar","c":[1,3,5]} | |
{"bb":{"e":"あ"},"a":"hoge","b":"bar","c":[1,3,5]} | |
true |
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
package example.misc; | |
import org.json.JSONObject; | |
public class JsonCompare { | |
public static void main(String[] args) { | |
final JSONObject o1 = new JSONObject("{\'a\': 'hoge', b: 'bar', c: [1,3,5], bb: {e: 'あ'}}"); | |
final JSONObject o2 = new JSONObject("{b: 'bar', \nc:[1,\n3,5], a: \n'hoge', \"bb\": {e: '\\u3042'}}"); | |
System.out.println(o1.toString()); | |
System.out.println(o2.toString()); | |
System.out.println(o1.toString().equals(o2.toString())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment