JSONTool

org.llm4s.toolapi.builtin.core.JSONTool
object JSONTool

Tool for JSON parsing, formatting, and querying.

Operations:

  • parse: Parse JSON string into structured data
  • format: Pretty-print JSON
  • query: Extract value using path (e.g., "data.users[0].name")
  • validate: Check if string is valid JSON

Limits and errors: a document nested more than 512 levels deep (arrays and objects counted together) is refused by every operation with an error instead of being read or written, because pretty-printing recurses once per level. A query path must be read completely: an empty segment (a..b, a.), an index that is not a non-negative whole number (a[x], a[-1]), or any other text the path syntax does not cover is an error naming the text it stopped at, and an array index too large for an Int is an error naming the index.

Attributes

Example
import org.llm4s.toolapi.builtin.core.JSONTool
val tools = new ToolRegistry(Seq(JSONTool.tool))
agent.run("Parse this JSON and extract the user's email", tools)
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
JSONTool.type

Members list

Value members

Concrete fields

val toolSafe: Result[ToolFunction[Map[String, Any], JSONResult]]

The JSON tool instance, returning a Result for safe error handling.

The JSON tool instance, returning a Result for safe error handling.

Attributes