java.lang.Object
io.getlime.security.powerauth.lib.cmd.util.JsonUtil

public class JsonUtil extends Object
Helper class for obtaining typed values from JSON.
Author:
Roman Strobl, roman.strobl@wultra.com
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    intValue(org.json.simple.JSONObject o, String key)
    Extract int value from JSON object stored using key with given key.
    static long
    longValue(org.json.simple.JSONObject o, String key)
    Extract long value from JSON object stored using key with given key.
    static String
    stringValue(org.json.simple.JSONObject o, String key)
    Extract String value from JSON object stored using key with given name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JsonUtil

      public JsonUtil()
  • Method Details

    • longValue

      public static long longValue(org.json.simple.JSONObject o, String key)
      Extract long value from JSON object stored using key with given key. In case the deserialized value type is not numeric, value 0 is returned.
      Parameters:
      o - JSON object.
      key - Key name.
      Returns:
      Extracted long value.
    • intValue

      public static int intValue(org.json.simple.JSONObject o, String key)
      Extract int value from JSON object stored using key with given key. In case the deserialized value type is not numeric, value 0 is returned.
      Parameters:
      o - JSON object.
      key - Key name.
      Returns:
      Extracted int value.
    • stringValue

      public static String stringValue(org.json.simple.JSONObject o, String key)
      Extract String value from JSON object stored using key with given name. In case the deserialized value type is not of String type, value "" is returned.
      Parameters:
      o - JSON object.
      key - Key name.
      Returns:
      Extracted String value.