Class JsonHelper


  • public final class JsonHelper
    extends Object
    A helper class for working with JsonObjects.
    • Method Detail

      • getValue

        public static <T> T getValue​(io.vertx.core.json.JsonObject jsonObject,
                                     String name,
                                     Class<T> clazz,
                                     T defaultValue)
        Gets a value from the given JSON object.
        Type Parameters:
        T - The type of the value.
        Parameters:
        jsonObject - The JSON object to get the value from.
        name - The key to return the value for.
        defaultValue - A default value to return if the value is null or is of an unexpected type.
        clazz - The target type.
        Returns:
        The value or the given default value if the value is not set or is of an unexpected type.
        Throws:
        NullPointerException - if any of the parameters except defaultValue is null.