Class ToolArgumentsParser

java.lang.Object
dev.langchain4j.internal.ToolArgumentsParser

public class ToolArgumentsParser extends Object
Leniently parses the JSON arguments of a tool execution request. Shared by the tool executor and the tool guardrail requests so both interpret arguments identically.
Since:
1.25.0
  • Method Details

    • argumentsAsMap

      public static Map<String,Object> argumentsAsMap(@Nullable String arguments)
      Converts a JSON arguments string to a map. Null or blank input, and the JSON literal null, give an empty map. If the first parse fails, the input is normalized (surrounding quotes removed, escaped quotes unescaped, trailing commas removed) and parsed once more; a second failure propagates.
      Parameters:
      arguments - json string
      Returns:
      the parsed map (mutable, unless it is empty), never null