private void applySection(PatchSection section) throws IOException {
		JsonArray path = section.path();
		List<PatchLine> lines = section.lines();

		JsonElement parent = findParent(path);
		JsonElement targetId =
			path.size() > 0 ? path.get(path.size() - 1) : new JsonPrimitive(ROOT_ELEM_NAME); // special case to handle bare values without container

		if (targetId instanceof JsonPrimitive prim && prim.isString() &&
			parent instanceof JsonObject parentObj) {
			String targetName = prim.getAsString();
			int i = 0;
			if (lines.get(i).operation() == PatchOp.REMOVE) {
				parentObj.remove(targetName);
				i++;
			}
			if (i < lines.size() && lines.get(i).operation() == PatchOp.ADD) {
				parentObj.add(targetName, lines.get(i).value());
			}
		}
		else if (targetId instanceof JsonPrimitive prim && prim.isNumber() &&
			parent instanceof JsonArray parentArray) {
			int targetIndex = prim.getAsInt();
			int i;
			for (i = 0; i < lines.size() && lines.get(i).operation() == PatchOp.REMOVE; i++) {
				parentArray.remove(targetIndex);
			}

			// icky logic because you can't insert in a JsonArray at arbitrary location
			List<JsonElement> arrayElems = new ArrayList<>(parentArray.size());
			parentArray.forEach(arrayElems::add);
			for (; i < lines.size() && lines.get(i).operation() == PatchOp.ADD; i++) {
				arrayElems.add(targetIndex, lines.get(i).value());
				targetIndex++;
			}
			if (arrayElems.size() != parentArray.size()) {
				while (parentArray.size() > 0) {
					parentArray.remove(parentArray.size() - 1);
				}
				arrayElems.forEach(parentArray::add);
			}
		}
		else {
			throw new IOException("unsupported section");
		}
	}
Simplistic implementation, applies a json diff (see https://github.com/josephburnett/jd)
to an in memory json element to create a new json value.
<p>
Does not use any context hints in the diff to correct for mismatches, hence should only be used
against the exact original value to produce the new value, useful for compressing json files
that are derived from each other.
Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/rtti/JsonPatchApplier.java