Class JsonTools

java.lang.Object
com.tnsai.tools.file.JsonTools

public class JsonTools extends Object
Function-shape JSON tools — the LangChain-style replacement for the legacy JSONQueryTool that crammed source + JsonPath into a single path|||expression text protocol (see issue #188 — RFC).

The legacy tool used AbstractTool.execute(String) with a ||| separator. Here the LLM gets two typed parameters and the body runs directly:


 jsonQuery(path = "/data/config.json", jsonPath = "$.database.host")
 

Path-detection rule preserved verbatim from the legacy tool for migration parity: ends with .json, starts with /, or starts with ./ → file path; anything else is treated as a raw JSON string.

Since:
0.5.7 (Phase 2 — built-in tool migration to function shape, see #188)
  • Field Details

    • DEFAULT_EXTENSIONS

      public static final Set<String> DEFAULT_EXTENSIONS
  • Constructor Details

    • JsonTools

      public JsonTools()
    • JsonTools

      public JsonTools(FileGuardConfig guardConfig)
  • Method Details

    • jsonQuery

      @Tool(name="json_query", description="Query JSON data with a JsonPath expression. The first argument is either a file path (.json suffix or starts with / or ./) or a literal JSON string. The second argument is a JsonPath expression like $.users[*].name, $..author, $.items[?(@.price<10)]. Returns the matched value(s) as a JSON-formatted string, or \'No results found for path: \u2026\' when the path matches nothing.", keywords={"json","jsonpath","query","extract"}, idempotent=true) public String jsonQuery(@ToolParam(description="Absolute file path to a .json file, or a literal JSON string") String path, @ToolParam(description="JsonPath expression \u2014 see https://github.com/json-path/JsonPath#operators") String jsonPath) throws IOException
      Throws:
      IOException