Class JSONField

java.lang.Object
com.unboundid.util.json.JSONField
All Implemented Interfaces:
Serializable

This class provides a simple data structure that represents a field in a JSON object, containing a name and a value. This is primarily intended as a convenience when programmatically constructing JSON objects.
See Also:
  • Constructor Details

    • JSONField

      public JSONField(@NotNull String name, @NotNull JSONValue value)
      Creates a new JSON field with the specified name and value.
      Parameters:
      name - The name for this field. It must not be null.
      value - The value for this field. It must not be null (although it may be a JSONNull instance).
    • JSONField

      public JSONField(@NotNull String name, boolean value)
      Creates a new JSON field with the specified name and a JSONBoolean value.
      Parameters:
      name - The name for this field. It must not be null.
      value - The value for this field. It must not be null.
    • JSONField

      public JSONField(@NotNull String name, long value)
      Creates a new JSON field with the specified name and a JSONNumber value.
      Parameters:
      name - The name for this field. It must not be null.
      value - The value for this field. It must not be null.
    • JSONField

      public JSONField(@NotNull String name, double value)
      Creates a new JSON field with the specified name and a JSONNumber value.
      Parameters:
      name - The name for this field. It must not be null.
      value - The value for this field. It must not be null.
    • JSONField

      public JSONField(@NotNull String name, @NotNull String value)
      Creates a new JSON field with the specified name and a JSONString value.
      Parameters:
      name - The name for this field. It must not be null.
      value - The value for this field. It must not be null.
  • Method Details

    • getName

      Retrieves the name for this field.
      Returns:
      The name for this field.
    • getValue

      Retrieves the value for this field.
      Returns:
      The value for this field.
    • hashCode

      public int hashCode()
      Retrieves a hash code for this JSON field.
      Overrides:
      hashCode in class Object
      Returns:
      A hash code for this JSON field.
    • equals

      public boolean equals(@Nullable Object o)
      Indicates whether the provided object is considered equal to this JSON field.
      Overrides:
      equals in class Object
      Parameters:
      o - The object for which to make the determination.
      Returns:
      true if the provided object is a JSON field with the same name and an equivalent value, or false if not.
    • toString

      Retrieves a string representation of this field.
      Overrides:
      toString in class Object
      Returns:
      A string representation of this field.
    • toString

      public void toString(@NotNull StringBuilder buffer)
      Appends a string representation of this field to the provided buffer.
      Parameters:
      buffer - The buffer to which the information should be appended.