public static void main(String[] args) {
String j1 = "{\"a\":2,\"f\":3}";
String j2 = "{\"f\":3, \"a\":2}";
Gson gson =new Gson();
JsonElement je1 = gson.fromJson(gson.toJson(j1),JsonElement.class);
JsonElement je2 =gson.fromJson(gson.toJson(j2),JsonElement.class);
System.out.println(je1);
System.out.println(je2);
System.out.println(je1.equals(je2));
JsonParser parser = new JsonParser();
JsonElement je3 = parser.parse(j1);
JsonElement je4 =parser.parse(j2);
System.out.println(je3);
System.out.println(je4);
System.out.println(je3.equals(je4));
}
结果