Module org.jooq
Package org.jooq

Class JSONB

java.lang.Object
org.jooq.JSONB
All Implemented Interfaces:
Serializable

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

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

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

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

This impacts the behaviour (and performance!) of

The data() content, however, is not normalised.

See Also:
  • Method Details

    • data

      @NotNull public final @NotNull String data()
    • valueOf

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

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

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

    • jsonbOrNull

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

      public int hashCode()

      JSONB specifics:

      The JSONB type uses a normalised representation of the JSON content, meaning that two equivalent JSON documents are considered equal (see JSONB for details). This impacts both behaviour and performance!

      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)

      JSONB specifics:

      The JSONB type uses a normalised representation of the JSON content, meaning that two equivalent JSON documents are considered equal (see JSONB for details). This impacts both behaviour and performance!

      Overrides:
      equals in class Object
    • toString

      public String toString()

      JSONB specifics:

      The JSONB type uses a normalised representation of the JSON content, meaning that two equivalent JSON documents are considered equal (see JSONB for details). This impacts both behaviour and performance!

      Overrides:
      toString in class Object