Class JSONUtil


  • public class JSONUtil
    extends Object
    Budding collection of useful tools for creating complex JSON objects.

    The structure of a JSON serialization is {name:{key0:val0,...}} where name is the name of the component e.g. client, admin, ldap,... etc. So this lets you create a JSON object that has a single JSON object as its value and directly do set/get against the value object.

    Created by Jeff Gaynor
    on 11/14/16 at 2:12 PM

    • Constructor Detail

      • JSONUtil

        public JSONUtil​(String componentName)
    • Method Detail

      • getComponentName

        public String getComponentName()
      • getJSONValue

        public Object getJSONValue​(net.sf.json.JSONObject json,
                                   String key)
      • getJSONArray

        public net.sf.json.JSONArray getJSONArray​(net.sf.json.JSONObject json,
                                                  String key)
      • getJSONValueString

        public String getJSONValueString​(net.sf.json.JSONObject json,
                                         String key)
      • hasKey

        public boolean hasKey​(net.sf.json.JSONObject json,
                              String key)
      • getJSONValueBoolean

        public boolean getJSONValueBoolean​(net.sf.json.JSONObject json,
                                           String key)
        get a boolean value. Returns false if no such value.
        Parameters:
        json -
        key -
        Returns:
      • getJSONValueLong

        public long getJSONValueLong​(net.sf.json.JSONObject json,
                                     String key)
      • getJSONValueInt

        public int getJSONValueInt​(net.sf.json.JSONObject json,
                                   String key)
      • setJSONValue

        public void setJSONValue​(net.sf.json.JSONObject json,
                                 String key,
                                 Object value)