ResourceUtil { public static boolean jsonEquals(JsonObject first, JsonObject second) { final ObjectMapper mapper = new ObjectMapper(); try { final JsonNode tree1 = mapper.readTree(first.toString()); final JsonNode tree2 = mapper.readTree(second.toString()); return tree1.equals(tree2); } catch (IOException e) { return false; } }  static boolean jsonEquals(JsonObject first, JsonObject second); static List<T> loadList(File file, Class<T> clazz); static T load(File file, Class<T> clazz); static T load(File file, Class<T> clazz, ResourceFileType resourceFileType); static T load(InputStream in, Class<T> clazz, ResourceFileType resourceFileType); static File save(File file, Object data); static File save(File file, Object data, ResourceFileType type); static String toYaml(Object resource); static String toJson(Object resource);  }
@Test public void simple() { JsonParser parser = new JsonParser(); JsonObject first = parser.parse("{first: bla, second: blub}").getAsJsonObject(); JsonObject same = parser.parse("{second: blub, first: bla }").getAsJsonObject(); JsonObject different = parser.parse("{second: blub, first: bla2 }").getAsJsonObject(); assertTrue(ResourceUtil.jsonEquals(first, same)); assertFalse(ResourceUtil.jsonEquals(first, different)); }