public static <T> Optional<T> optional(Inspector field, Function<Inspector, T> factory) {
        return isPresent(field) ? Optional.of(factory.apply(field)) : Optional.empty();
    }
Throws {@link JsonParseException} on invalid JSON.
vespajlib/src/main/java/com/yahoo/slime/SlimeUtils.java