Class VariantJsonFormat

java.lang.Object
dev.frostlake.values.VariantJsonFormat

public final class VariantJsonFormat extends Object
Renders a semi-structured value the way Snowflake displays one: indented by JSON_INDENT spaces, compact at zero. An empty array or object stays on one line either way. The indented form is byte-identical to a real account's at the same width.

The width is per session, so it is bound to the calling thread for the duration of a statement — the same shape the catalog and transaction manager use for their session scopes. Nothing else about the value changes: equality, ordering and hashing all stay on the canonical compact text.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The width this engine uses when a session has not set one.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    beginSessionScope(int indent)
    Bind this session's JSON_INDENT to the calling thread for one statement.
    static void
    Drop this thread's JSON_INDENT binding.
    static int
    The width in force: the session's when one is bound, else Snowflake's default.
    static String
    render(tools.jackson.databind.JsonNode node, String compactText)
    node rendered at the width in force.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_INDENT

      public static final int DEFAULT_INDENT
      The width this engine uses when a session has not set one. Snowflake's own JSON_INDENT default is 2; this engine's canonical rendering is COMPACT, and the live-comparison harness pins the server to JSON_INDENT = 0 so both sides emit the same text. Setting the parameter gives live's rendering at any width — only the unset default differs.
      See Also:
  • Method Details

    • beginSessionScope

      public static void beginSessionScope(int indent)
      Bind this session's JSON_INDENT to the calling thread for one statement.
    • clearSessionScope

      public static void clearSessionScope()
      Drop this thread's JSON_INDENT binding. Idempotent.
    • indent

      public static int indent()
      The width in force: the session's when one is bound, else Snowflake's default.
    • render

      public static String render(tools.jackson.databind.JsonNode node, String compactText)
      node rendered at the width in force. compactText, the value's compact display text, is returned unchanged at width zero, so the common case costs nothing.