private void diffObject(String path, JsonObject source, JsonObject target) { source.forEach((key, value) -> { if (target.containsKey(key)) { diff(path + '/' + key, value, target.get(key)); } else { builder.remove(path + '/' + key); } }); target.forEach((key, value) -> { if (! source.containsKey(key)) { builder.add(path + '/' + key, value); } }); }
private void diffObject(String path, JsonObject source, JsonObject target) { source.forEach((key, value) -> { if (target.containsKey(key)) { diff(path + '/' + key, value, target.get(key)); } else { builder.remove(path + '/' + key); } }); target.forEach((key, value) -> { if (! source.containsKey(key)) { builder.add(path + '/' + key, value); } }); }
private void diffJsonObjects(JsonPatchBuilder patchBuilder, String basePath, JsonObject source, JsonObject target) { for (Map.Entry<String, JsonValue> sourceEntry : source.entrySet()) { String attributeName = sourceEntry.getKey(); if (target.containsKey(attributeName)) { diff(patchBuilder, basePath + JsonPointerUtil.encode(attributeName), sourceEntry.getValue(), target.get(attributeName)); } else { // the value got removed patchBuilder.remove(basePath + JsonPointerUtil.encode(attributeName)); } } for (Map.Entry<String, JsonValue> targetEntry : target.entrySet()) { if (!source.containsKey(targetEntry.getKey())) { patchBuilder.add(basePath + JsonPointerUtil.encode(targetEntry.getKey()), targetEntry.getValue()); } } }
private void diffJsonObjects(JsonPatchBuilder patchBuilder, String basePath, JsonObject source, JsonObject target) { for (Map.Entry<String, JsonValue> sourceEntry : source.entrySet()) { String attributeName = sourceEntry.getKey(); if (target.containsKey(attributeName)) { diff(patchBuilder, basePath + JsonPointerUtil.encode(attributeName), sourceEntry.getValue(), target.get(attributeName)); } else { // the value got removed patchBuilder.remove(basePath + JsonPointerUtil.encode(attributeName)); } } for (Map.Entry<String, JsonValue> targetEntry : target.entrySet()) { if (!source.containsKey(targetEntry.getKey())) { patchBuilder.add(basePath + JsonPointerUtil.encode(targetEntry.getKey()), targetEntry.getValue()); } } }
private void diffObject(String path, JsonObject source, JsonObject target) { source.forEach((key, value) -> { if (target.containsKey(key)) { diff(path + '/' + key, value, target.get(key)); } else { builder.remove(path + '/' + key); } }); target.forEach((key, value) -> { if (! source.containsKey(key)) { builder.add(path + '/' + key, value); } }); }
private void diffObject(String path, JsonObject source, JsonObject target) { source.forEach((key, value) -> { if (target.containsKey(key)) { diff(path + '/' + key, value, target.get(key)); } else { builder.remove(path + '/' + key); } }); target.forEach((key, value) -> { if (! source.containsKey(key)) { builder.add(path + '/' + key, value); } }); }
private void diffObject(String path, JsonObject source, JsonObject target) { source.forEach((key, value) -> { if (target.containsKey(key)) { diff(path + '/' + key, value, target.get(key)); } else { builder.remove(path + '/' + key); } }); target.forEach((key, value) -> { if (! source.containsKey(key)) { builder.add(path + '/' + key, value); } }); }
private void diffObject(String path, JsonObject source, JsonObject target) { source.forEach((key, value) -> { if (target.containsKey(key)) { diff(path + '/' + key, value, target.get(key)); } else { builder.remove(path + '/' + key); } }); target.forEach((key, value) -> { if (! source.containsKey(key)) { builder.add(path + '/' + key, value); } }); }
private void diffJsonArray(JsonPatchBuilder patchBuilder, String basePath, JsonArray source, JsonArray target) { for (int i = 0; i < source.size(); i++) { JsonValue sourceValue = source.get(i); if (target.size() <= i) { patchBuilder.remove(basePath + i); continue; } diff(patchBuilder, basePath + i, sourceValue, target.get(i)); } if (target.size() > source.size()) { for (int i = target.size() - source.size(); i < target.size(); i++) { patchBuilder.add(basePath + i, target.get(i)); } } }
private void diffJsonArray(JsonPatchBuilder patchBuilder, String basePath, JsonArray source, JsonArray target) { for (int i = 0; i < source.size(); i++) { JsonValue sourceValue = source.get(i); if (target.size() <= i) { patchBuilder.remove(basePath + i); continue; } diff(patchBuilder, basePath + i, sourceValue, target.get(i)); } if (target.size() > source.size()) { for (int i = target.size() - source.size(); i < target.size(); i++) { patchBuilder.add(basePath + i, target.get(i)); } } }