Class JSONMap

All Implemented Interfaces:
Serializable, Cloneable, Map<String,​Object>

public class JSONMap extends HashMap<String,​Object>
See Also:
Serialized Form
  • Constructor Details

    • JSONMap

      public JSONMap(Map map)
    • JSONMap

      public JSONMap(String... keysAndValues)
      Creates a ne instance from the array, where odd arguments are map keys and the even are values.
      Parameters:
      keysAndValues - keys and
    • JSONMap

      public JSONMap()
  • Method Details

    • get

      public Object get(Object attributePath)
      Returns an object deep from the structure of a JSON document.
           {
               "university": {
                   students : {
                       "mary" : {
                                 "first_name": "Mary",
                                 "last_name": "Smith",
                        },
                       "joe" : {
                           "first_name": "Joe",
                           "last_name": "Shmoe",
                       }
                   }
               }
           }
       
      Specified by:
      get in interface Map<String,​Object>
      Overrides:
      get in class HashMap<String,​Object>
      Parameters:
      attributePath - accepts a dot-delimited format: "university.students.joe" where every entry except the last one must be a map
      Returns:
      an object from the depths of the JSON structure.
    • getMap

      public JSONMap getMap(String attributePath)
      Returns a map deep from the structure of a JSON document.
           {
               "university": {
                   students : {
                       "mary" : {
                                 "first_name": "Mary",
                                 "last_name": "Smith",
                        },
                       "joe" : {
                           "first_name": "Joe",
                           "last_name": "Shmoe",
                       }
                   }
               }
           }
       
      Parameters:
      attributePath - accepts a dot-delimited format: "university.students.joe" where every entry must be a map
      Returns:
      a map from the depths of the JSON structure.
    • getList

      public JSONList getList(String attributePath)
      Returns a list deep from the structure of JSON document.
           {
               "university": {
                   students : ["mary", joe]
      
               }
           }
       
      Parameters:
      attributePath - accepts a dot-delimited format: "university.students" where every entry must be a map
      Returns:
      list from the depths of the JSON structure.
    • getBoolean

      public Boolean getBoolean(String attributePath)
      Parameters:
      attributePath - accepts a dot-delimited format: "university.students" where every entry must be a map.
    • getBigDecimal

      public BigDecimal getBigDecimal(String attributePath)
      Parameters:
      attributePath - accepts a dot-delimited format: "university.students" where every entry must be a map.
    • getDate

      public Date getDate(String attributePath)
      Parameters:
      attributePath - accepts a dot-delimited format: "university.students" where every entry must be a map.
    • getDouble

      public Double getDouble(String attributePath)
      Parameters:
      attributePath - accepts a dot-delimited format: "university.students" where every entry must be a map.
    • getFloat

      public Float getFloat(String attributePath)
      Parameters:
      attributePath - accepts a dot-delimited format: "university.students" where every entry must be a map.
    • getInteger

      public Integer getInteger(String attributePath)
      Parameters:
      attributePath - accepts a dot-delimited format: "university.students" where every entry must be a map.
    • getLong

      public Long getLong(String attributePath)
      Parameters:
      attributePath - accepts a dot-delimited format: "university.students" where every entry must be a map.
    • getShort

      public Short getShort(String attributePath)
      Parameters:
      attributePath - accepts a dot-delimited format: "university.students" where every entry must be a map.
    • getString

      public String getString(String attributePath)
      Parameters:
      attributePath - accepts a dot-delimited format: "university.students" where every entry must be a map.
    • toString

      public String toString()
      Overrides:
      toString in class AbstractMap<String,​Object>
      Returns:
      a JSON representation of this object
    • toJSON

      public String toJSON(boolean pretty)
      Parameters:
      pretty - - true for formatted JSON.
      Returns:
      a JSON representation of this object
    • toJSON

      public String toJSON()
      Returns:
      a JSON representation of this object