///|
/// Replace selected JSON Pointer values before logging or displaying a
/// document. The original value is never mutated and the result is canonical.
pub fn redact_document(
  input : String,
  pointers : Array[String],
  replacement_json : String,
) -> Result[String, String] {
  let value = match parse(input) {
    Ok(value) => value
    Err(error) => return Err(error.message())
  }
  let replacement = match parse(replacement_json) {
    Ok(value) => value
    Err(error) => return Err("replacement: " + error.message())
  }
  let operations : Array[PatchOperation] = []
  for pointer in pointers {
    operations.push(patch_replace(pointer, replacement))
  }
  match apply_patch(value, operations) {
    Ok(value) =>
      match canonicalize(value) {
        Ok(output) => Ok(output)
        Err(error) => Err(error.message())
      }
    Err(error) => Err(error)
  }
}