List of usage examples for com.google.gson JsonArray equals
@Override public boolean equals(Object o)
From source file:com.arangodb.entity.EntityDeserializers.java
License:Apache License
private static List<PathEntity<Object, Object>> getPaths(JsonDeserializationContext context, JsonObject visited, Class<?> vertexClazz, Class<?> edgeClazz) { List<PathEntity<Object, Object>> pathEntities = new ArrayList<PathEntity<Object, Object>>(); JsonArray paths = visited.getAsJsonArray("paths"); if (!paths.equals(null)) { for (int i = 0, imax = paths.size(); i < imax; i++) { JsonObject path = paths.get(i).getAsJsonObject(); PathEntity<Object, Object> pathEntity = new PathEntity<Object, Object>(); if (path.has("edges")) { pathEntity.setEdges(getEdges(edgeClazz, context, path.getAsJsonArray("edges"))); }/*from w w w.j a v a 2 s. c o m*/ if (path.has("vertices")) { pathEntity.setVertices(getVertices(vertexClazz, context, path.getAsJsonArray("vertices"))); } pathEntities.add(pathEntity); } } return pathEntities; }
From source file:com.arangodb.entity.EntityDeserializers.java
License:Apache License
private static List<VertexEntity<Object>> getVertices(Class<?> vertexClazz, JsonDeserializationContext context, JsonArray vertices) { List<VertexEntity<Object>> list = new ArrayList<VertexEntity<Object>>(); if (!vertices.equals(null)) { for (int i = 0, imax = vertices.size(); i < imax; i++) { JsonObject vertex = vertices.get(i).getAsJsonObject(); VertexEntity<Object> ve = getVertex(context, vertex, vertexClazz); list.add(ve);//from ww w .j a va2s.co m } } return list; }
From source file:com.arangodb.entity.EntityDeserializers.java
License:Apache License
private static List<EdgeEntity<Object>> getEdges(Class<?> edgeClazz, JsonDeserializationContext context, JsonArray edges) { List<EdgeEntity<Object>> list = new ArrayList<EdgeEntity<Object>>(); if (!edges.equals(null)) { for (int i = 0, imax = edges.size(); i < imax; i++) { JsonObject edge = edges.get(i).getAsJsonObject(); EdgeEntity<Object> ve = deserializeBaseParameter(edge, new EdgeEntity<Object>()); deserializeDocumentParameter(edge, ve); if (edgeClazz != null) { ve.setEntity(context.deserialize(edge, edgeClazz)); } else { ve.setEntity(context.deserialize(edge, Object.class)); }// w w w . j av a2s . c om list.add(ve); } } return list; }
From source file:com.ca.dvs.utilities.raml.JsonUtil.java
License:Open Source License
/** * Compare two JSON strings/*from w w w . ja va2s . com*/ * @param json1 the first of two JSON objects to compare * @param json2 the second of two JSON objects to compare * @return true when the JSON strings compare favorably, otherwise false */ public static boolean equals(String json1, String json2) { boolean match = false; if (null != json1 && null != json2) { JsonParser parser = new JsonParser(); Object obj1 = parser.parse(json1); Object obj2 = parser.parse(json2); if (obj1 instanceof JsonObject && obj2 instanceof JsonObject) { JsonObject jObj1 = (JsonObject) obj1; JsonObject jObj2 = (JsonObject) obj2; match = jObj1.equals(jObj2); } else if (obj1 instanceof JsonArray && obj2 instanceof JsonArray) { JsonArray jAry1 = (JsonArray) obj1; JsonArray jAry2 = (JsonArray) obj2; match = jAry1.equals(jAry2); } } return match; }
From source file:com.ls.util.internal.ObjectComparator.java
License:Open Source License
private static Object getDifferencesForArrays(JsonArray origin, JsonArray patched) { if (origin.equals(patched)) { return UNCHANGED; }/*w w w . j a v a 2 s . c o m*/ //TODO improve differences calculation for arrays. return convertElementToStringRepresentation(patched); }