Class JsonUtils

java.lang.Object
de.christofreichardt.json.JsonUtils

public class JsonUtils extends Object
Provides some utility functions.
Author:
Christof Reichardt
  • Method Details

    • orElseThrow

      public static <T extends jakarta.json.JsonValue> T orElseThrow(jakarta.json.JsonObject jsonObject, String key, Class<T> jsonType)
      Used to access a typed name/value pair of the given JsonObject. Either if the name/value pair doesn't exist or if the requested type of the value cannot be satisfied an IllegalArgumentException will be thrown. At present only JsonString values can be requested.
      Type Parameters:
      T - the type of the JsonValue
      Parameters:
      jsonObject - the object to be worked with
      key - the key whose associated value we are interested in
      jsonType - the desired class of the JsonValue
      Returns:
      the associated value