Class JsonHelper

java.lang.Object
org.qubership.atp.ram.utils.JsonHelper

public class JsonHelper extends Object
  • Method Details

    • getStringValue

      public static String getStringValue(com.google.gson.JsonObject jsonObject, String key, String defaultValue)
      Check value in JsonObject by key and return string value.
      Parameters:
      jsonObject - JsonObject for find value
      key - for find value
      defaultValue - return when value not exist or empty
      Returns:
      value by key or default value
    • getStringValue

      public static String getStringValue(com.google.gson.JsonObject jsonObject, String key)
      Check value in JsonObject by key and return string value.
      Parameters:
      jsonObject - JsonObject for find value
      key - for find value
      Returns:
      value by key or empty
    • getListString

      public static List<String> getListString(com.google.gson.JsonObject jsonObject, String key, List<String> defaultValue)
      Check value in JsonObject by key and return string array.
      Parameters:
      jsonObject - JsonObject for find value
      key - for find value
      defaultValue - return when value not exist or empty
      Returns:
      list of string by key or default list
    • getLongValue

      public static Long getLongValue(com.google.gson.JsonObject jsonObject, String key) throws Exception
      Check value in JsonObject by key and return long value.
      Parameters:
      jsonObject - JsonObject for find value
      key - for find value
      Returns:
      long value by key or System.currentTimeMillis
      Throws:
      Exception
    • getExecutionStatus

      public static ExecutionStatuses getExecutionStatus(com.google.gson.JsonObject jsonObject, String key, ExecutionStatuses defaultStatus)
      Check value in JsonObject by key and return ExecutionStatuses.
      Parameters:
      jsonObject - JsonObject for find value
      key - for find value
      Returns:
      status by key or default status
    • getTestingStatus

      public static TestingStatuses getTestingStatus(com.google.gson.JsonObject jsonObject, String key, TestingStatuses defaultStatus)
      Check value in JsonObject by key and return TestingStatuses.
      Parameters:
      jsonObject - JsonObject for find value
      key - for find value
      Returns:
      status by key or default status
    • getBooleanValue

      public static boolean getBooleanValue(com.google.gson.JsonObject request, String key)
      Check value in JsonObject by key and return boolean value.
      Parameters:
      request - JsonObject for find value
      key - for find value
      Returns:
      value by key or false
    • getHashSet

      public static HashSet<String> getHashSet(com.google.gson.JsonObject jsonObject, String key, HashSet<String> defaultValue)
      Check value in JsonObject by key and return HashSet.
      Parameters:
      jsonObject - JsonObject for find value.
      key - for find value.
      defaultValue - return when value not exist or empty.
      Returns:
      value by key or empty
    • getUuidValue

      public static UUID getUuidValue(com.google.gson.JsonObject jsonObject, String key)