Interface JsonValue

All Known Subinterfaces:
JsonOperations.JsonResult

public interface JsonValue
Value abstraction for JSON payloads passed to RedisJsonCommands.
Since:
4.2
Author:
Yordan Tsintsov, Mark Paluch
  • Method Details

    • nullValue

      static JsonValue nullValue()
      JSON null value.
      Returns:
      JsonValue representing JSON null.
    • of

      static JsonValue of(boolean value)
      JSON boolean from a boolean.
      Parameters:
      value - the boolean value.
      Returns:
      JsonValue representing JSON boolean.
    • of

      static JsonValue of(Number number)
      JSON number from a Number.
      Parameters:
      number - must not be null.
      Returns:
      JsonValue representing JSON number.
    • of

      static JsonValue of(int number)
      JSON number from an int.
      Parameters:
      number - the value.
      Returns:
      JsonValue representing JSON number.
    • of

      static JsonValue of(long number)
      JSON number from a long.
      Parameters:
      number - the value.
      Returns:
      JsonValue representing JSON number.
    • of

      static JsonValue of(float number)
      JSON number from a float.
      Parameters:
      number - the value, must be finite.
      Returns:
      JsonValue representing JSON number.
    • of

      static JsonValue of(double number)
      JSON number from a double.
      Parameters:
      number - the value, must be finite.
      Returns:
      JsonValue representing JSON number.
    • of

      static JsonValue of(String value)
      JSON string from a Java String.
      Parameters:
      value - must not be null.
      Returns:
      JsonValue representing JSON string.
    • raw

      static JsonValue raw(byte[] json)
      JSON value from a JSON document. The supplied text is assumed to represent valid JSON in bytes. It is used as-is.
      Parameters:
      json - a valid JSON document, must not be null.
      Returns:
      a JsonValue carrying the JSON.
    • raw

      static JsonValue raw(String json)
      JSON value from a JSON document. The supplied text is assumed to represent valid JSON. It is used as-is after UTF-8 conversion.
      Parameters:
      json - a valid JSON document, must not be null.
      Returns:
      a JsonValue carrying the JSON.
    • asBytes

      byte[] asBytes()
      Return the JSON representation of this value as raw bytes.
      Returns:
      the raw JSON bytes. Returns "null" if the value is nullValue().
    • asString

      @Nullable String asString()
      Return the JSON representation of this value as String.
      Returns:
      the JSON as UTF-8 String, can be null if the value is null or the key is absent.