Class JsonUtils

java.lang.Object
com.michelin.cert.redscan.utils.json.JsonUtils

public class JsonUtils extends Object
Json Utils.
Author:
Maxime ESCOURBIAC
  • Constructor Details

    • JsonUtils

      public JsonUtils()
  • Method Details

    • getSafeString

      public static String getSafeString(kong.unirest.json.JSONObject json, String key)
      Safe method to extract string from Json Object.
      Parameters:
      json - Json object.
      key - Key to extract.
      Returns:
      Get the string associated with a key.
    • setSafeString

      public static void setSafeString(kong.unirest.json.JSONObject json, String key, String value)
      Safe method to inject string to Json Object.
      Parameters:
      json - Json object.
      key - Key to inject.
      value - Value to inject.
    • getSafeInt

      public static int getSafeInt(kong.unirest.json.JSONObject json, String key)
      Safe method to extract int from Json Object.
      Parameters:
      json - Json object.
      key - Key to extract.
      Returns:
      Get the int associated with a key.
    • setSafeInt

      public static void setSafeInt(kong.unirest.json.JSONObject json, String key, int value)
      Safe method to inject int to Json Object.
      Parameters:
      json - Json object.
      key - Key to inject.
      value - Value to inject.
    • getSafeBoolean

      public static boolean getSafeBoolean(kong.unirest.json.JSONObject json, String key)
      Safe method to extract boolean from Json Object.
      Parameters:
      json - Json object.
      key - Key to extract.
      Returns:
      Get the boolean associated with a key.
    • setSafeBoolean

      public static void setSafeBoolean(kong.unirest.json.JSONObject json, String key, Boolean value)
      Safe method to inject boolean to Json Object.
      Parameters:
      json - Json object.
      key - Key to inject.
      value - Value to inject.
    • getSafeStringArray

      public static String[] getSafeStringArray(kong.unirest.json.JSONObject json, String key)
      Safe method to inject string array to Json Object.
      Parameters:
      json - Json object.
      key - Key to extract.
      Returns:
      Get the string array associated with a key.
    • setSafeStringArray

      public static void setSafeStringArray(kong.unirest.json.JSONObject json, String key, String[] values)
      Safe method to inject string array to Json Object.
      Parameters:
      json - Json object.
      key - Key to inject.
      values - Values to inject.