@Override
    public LayerSpec deserialize(JsonParser jsonParser, DeserializationContext context)
        throws IOException {
      JsonNode node = jsonParser.getCodec().readTree(jsonParser);
      if (!node.has("name")) {
        throw new IOException("Could not parse layer entry, missing required property 'name'");
      }
      if (node.has("archive")) {
        return jsonParser.getCodec().treeToValue(node, ArchiveLayerSpec.class);
      }
      if (node.has("files")) {
        return jsonParser.getCodec().treeToValue(node, FileLayerSpec.class);
      }
      throw new IOException("Could not parse entry into ArchiveLayer or FileLayer");
    }
Deserializes to {@link ArchiveLayerSpec} if yaml contains "archive" field, to {@link
FileLayerSpec} if yaml contains "files" field or throws {@link IOException} if neither is
found or no "name" was specified for the layer entry.
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/LayerSpec.java