Module org.jooq
Package org.jooq

Class JSON

java.lang.Object
org.jooq.JSON
All Implemented Interfaces:
Serializable, Data

public final class JSON extends Object implements Data
A JSON wrapper type for JSON data obtained from the database.

The wrapper represents JSON data() in serialised string form. A CAST(NULL AS JSON) value is represented by a null reference of type JSON, not as data() == null. This is consistent with jOOQ's general way of returning NULL from Result and Record methods.

Unlike the normalising JSONB data type, the JSON type uses a purely text based, formatting-preserving representation of the JSON content, meaning that e.g. the following two documents are not equal, due to their different object attribute order and formatting:

  • {"a":1,"b":2}
  • {"b": 2, "a": 1}

This impacts the behaviour of

See Also:
  • Method Details

    • data

      @NotNull public final @NotNull String data()
      Description copied from interface: Data
      Get the vendor specific String representation of this Data object.
      Specified by:
      data in interface Data
    • valueOf

      @NotNull public static final @NotNull JSON valueOf(String data)
      Create a new JSON instance from string data input.
    • json

      @NotNull public static final @NotNull JSON json(String data)
      Create a new JSON instance from string data input.

      This is the same as valueOf(String), but it can be static imported.

    • jsonOrNull

      @Nullable public static final @Nullable JSON jsonOrNull(String data)
      Create a new JSON instance from string data input, or null if the input is null.
    • hashCode

      public int hashCode()

      JSON specifics:

      The JSON type uses a text-based, formatting-preserving representation of the JSON content, meaning that two equivalent JSON documents are considered not equal if their formatting or object attribute ordering differs (see JSON for details).

      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)

      JSON specifics:

      The JSON type uses a text-based, formatting-preserving representation of the JSON content, meaning that two equivalent JSON documents are considered not equal if their formatting or object attribute ordering differs (see JSON for details).

      Overrides:
      equals in class Object
    • toString

      public String toString()

      JSON specifics:

      The JSON type uses a text-based, formatting-preserving representation of the JSON content, meaning that two equivalent JSON documents are considered not equal if their formatting or object attribute ordering differs (see JSON for details).

      Overrides:
      toString in class Object