jsontool

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package jsontool provides JSON querying, validation, and transformation tools backed by gjson (reads) and sjson (writes). These libraries support powerful dot-path syntax with array indexing, wildcards, and modifiers — far superior to hand-rolled path traversal.

Problem: Agents frequently need to extract values from API responses, transform configuration files, or validate JSON payloads. LLMs are unreliable at mentally navigating deeply nested JSON structures. This package provides precise, deterministic JSON operations.

gjson path syntax examples:

"name.first"           → nested key access
"friends.#"            → array length
"friends.0.name"       → first element
"friends.#.name"       → all names from array
"friends.#(age>40)"    → filter by condition
"friends.#(name%\"*ob*\")" → wildcard match

Safety guards:

  • Output truncated at 32 KB to limit LLM context consumption

Dependencies:

  • github.com/tidwall/gjson — high-performance JSON query (14k+ ⭐)
  • github.com/tidwall/sjson — JSON mutation via path syntax (2k+ ⭐)
  • No external system dependencies

See https://github.com/tidwall/gjson for full syntax.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ToolProvider

type ToolProvider struct{}

ToolProvider wraps the JSON tool and satisfies the tools.ToolProviders interface.

func NewToolProvider

func NewToolProvider() *ToolProvider

NewToolProvider creates a ToolProvider for the JSON tool.

func (*ToolProvider) GetTools

func (p *ToolProvider) GetTools() []tool.Tool

GetTools returns the JSON tool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL