Class RawJson

java.lang.Object
io.moderne.jsonrpc.RawJson

public final class RawJson extends Object
Library-owned wrapper for the params, result, and inbound error JSON values on JSON-RPC messages. Holds either:
  • a POJO (outbound — wrapped at request construction, serialized through whatever the MessageFormatter uses on the wire), or
  • a parser-format-specific buffer (inbound — produced by the formatter during deserialize; converted lazily to a typed POJO when the consumer asks via as(MessageFormatter, Class)), or
  • null.
Keeps Jackson types out of the public ABI: consumers see only library classes, so adding/upgrading/swapping the wire format does not force them to recompile.
  • Method Details

    • of

      public static RawJson of(@Nullable Object value)
      Wrap an arbitrary value. null returns the canonical null instance (no allocation per call).
    • isNull

      public boolean isNull()
    • as

      public <T> @Nullable T as(MessageFormatter formatter, Class<T> type)
      Convert this value to type using formatter. Returns null when isNull(); otherwise delegates to MessageFormatter.convertValue(RawJson, Type).
    • as

      public <T> @Nullable T as(MessageFormatter formatter, Type type)
    • unwrap

      public @Nullable Object unwrap()
      Internal accessor for MessageFormatter implementations and the default Jackson serializer. Returns the wrapped value (POJO, parser buffer, or null). Library consumers should use as(MessageFormatter, Class) instead — calling unwrap() directly couples them to the wire format.