
org.opentripplanner.framework.json.JsonUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
The newest version!
package org.opentripplanner.framework.json;
import com.fasterxml.jackson.databind.JsonNode;
import java.util.Optional;
import javax.annotation.Nonnull;
public class JsonUtils {
public static Optional asText(@Nonnull JsonNode node, @Nonnull String field) {
JsonNode valueNode = node.get(field);
if (valueNode == null) {
return Optional.empty();
}
String value = valueNode.asText();
return value.isEmpty() ? Optional.empty() : Optional.of(value);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy