借助com.google.gson包比较2个json是否相等,忽略json数组的顺序
/**
* 比较两个JsonElement是否相等,json数组顺序不影响
* @param jsonElementX
* @param jsonElementY
* @return
*/
public static boolean isJsonElementEquals(JsonElement jsonElementX, JsonElement jsonElementY){
if(jsonElementX.isJsonObject() && jsonElementY.isJsonObject()){
JsonObject jsonObjectX = (JsonObject)jsonElementX;
JsonObject jsonObjectY = (JsonObject)jsonElementY;
if(jsonObjectX.entrySet().size()!=jsonObjectY.entrySet().size())return false;
for(Map.Entry<String,JsonElement>jsonElementEntryX:jsonObjectX.entrySet()) {
boolean flag = false;
for(Map.Entry<String,JsonElement>jsonElementEntryY:jsonObjectX.entrySet()) {
* 比较两个JsonElement是否相等,json数组顺序不影响
* @param jsonElementX
* @param jsonElementY
* @return
*/
public static boolean isJsonElementEquals(JsonElement jsonElementX, JsonElement jsonElementY){
if(jsonElementX.isJsonObject() && jsonElementY.isJsonObject()){
JsonObject jsonObjectX = (JsonObject)jsonElementX;
JsonObject jsonObjectY = (JsonObject)jsonElementY;
if(jsonObjectX.entrySet().size()!=jsonObjectY.entrySet().size())return false;
for(Map.Entry<String,JsonElement>jsonElementEntryX:jsonObjectX.entrySet()) {
boolean flag = false;
for(Map.Entry<String,JsonElement>jsonElementEntryY:jsonObjectX.entrySet()) {