Enum Class OutputFormat

java.lang.Object
java.lang.Enum<OutputFormat>
com.tnsai.output.OutputFormat
All Implemented Interfaces:
Serializable, Comparable<OutputFormat>, Constable

public enum OutputFormat extends Enum<OutputFormat>
Supported output formats for structured agent responses. Each format has different trade-offs between human readability, token efficiency, and data structure support.

Token efficiency comparison (approximate):

  • JSON: Baseline (universal, verbose)
  • YAML: ~10-15% fewer tokens (human-readable, good for nested)
  • TOON: ~40% fewer tokens (tabular arrays, uniform data)
  • TONL: ~32-50% fewer tokens (schema-typed, large datasets)
  • Enum Constant Details

    • JSON

      public static final OutputFormat JSON
      JSON (JavaScript Object Notation). Universal format, widely supported, verbose but reliable. Best for: API responses, complex nested structures, interoperability.
    • YAML

      public static final OutputFormat YAML
      YAML (YAML Ain't Markup Language). Human-readable, indentation-based, good for configuration. Best for: Spec files, human review, nested data.
    • TOON

      public static final OutputFormat TOON
      TOON (Token-Optimized Object Notation). Combines YAML-style nesting with CSV-style tabular arrays. Best for: Uniform arrays of objects, LLM token optimization.
      See Also:
    • TONL

      public static final OutputFormat TONL
      TONL (Token-Optimized Notation Language). Table-like format with schema support. Best for: Large datasets, typed data, maximum token savings.
      See Also:
    • TEXT

      public static final OutputFormat TEXT
      Plain Text. Unstructured text output. Best for: Simple messages, creative writing, non-structured data.
  • Method Details

    • values

      public static OutputFormat[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static OutputFormat valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getExtension

      public String getExtension()
      Gets the file extension for this format.
    • getMimeType

      public String getMimeType()
      Gets the MIME type for this format.
    • supportsNesting

      public boolean supportsNesting()
      Returns true if this format supports nested/hierarchical data.
    • fromString

      public static OutputFormat fromString(String value)
      Parses a format from string (case-insensitive).
      Parameters:
      value - the format name
      Returns:
      the OutputFormat
      Throws:
      IllegalArgumentException - if format is unknown