static void writeImageJson(Optional<Path> imageJsonOutputPath, JibContainer jibContainer)
      throws IOException {
    if (imageJsonOutputPath.isPresent()) {
      ImageMetadataOutput metadataOutput = ImageMetadataOutput.fromJibContainer(jibContainer);
      Files.write(
          imageJsonOutputPath.get(), metadataOutput.toJson().getBytes(StandardCharsets.UTF_8));
    }
  }
Writes image details (imageId, digest, tags, etc.) to a json file, if the path to the json is
provided.

@param imageJsonOutputPath optional path to json file (for example,
    path/to/json/jib-image.json)
@param jibContainer the {@link JibContainer} to derive image details from
@throws IOException if error occurs when writing to the json file.
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/JibCli.java