Data & Analysis
Parse, query, extract, and reshape JSON.
json_transformMost online services return data in a format called JSON. This tool lets the agent grab a specific field out of that reply, reshape it, or convert it to a spreadsheet — the plumbing that chains steps of a workflow together.
Accepts a JSON payload and applies one of four operations: 'extract' pulls a single value at a dot-notation path (e.g. 'user.email'); 'query' returns all values matching a path; 'flatten' converts a nested object into a flat key-value map; 'to_csv' converts a JSON array of objects into a CSV string.
When a user asks:
Pull the user's email out of this API response.
the agent calls the tool:
json_transform(json="{…}", operation="extract", path="user.email")and gets back: the single value at that path — e.g. "jane@example.com".
Wire this tool into a SwarmAI crew. Use the YAML DSL for declarative workflows, or the Java builder API when you want full programmatic control.
YAML DSL
# data-glue.yaml
name: data-glue-crew
process: SEQUENTIAL
agents:
- id: shaper
role: Data Glue
goal: Reshape JSON between pipeline steps
tools:
- json_transform
tasks:
- id: data-glue-task
agent: shaper
description: Extract the 'user.email' field from the supplied JSON payload.Java
import ai.intelliswarm.swarmai.agent.Agent;
import ai.intelliswarm.swarmai.task.Task;
import ai.intelliswarm.swarmai.swarm.Swarm;
import ai.intelliswarm.swarmai.swarm.SwarmOutput;
import ai.intelliswarm.swarmai.process.ProcessType;
import ai.intelliswarm.swarmai.tool.common.JSONTransformTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
@Autowired ChatClient chatClient;
@Autowired JSONTransformTool jSONTransformTool;
Agent shaper = Agent.builder()
.role("Data Glue")
.goal("Reshape JSON between pipeline steps")
.chatClient(chatClient)
.tool(jSONTransformTool)
.build();
Task shaperTask = Task.builder()
.description("Extract the 'user.email' field from the supplied JSON payload.")
.agent(shaper)
.build();
SwarmOutput result = Swarm.builder()
.agent(shaper)
.task(shaperTask)
.process(ProcessType.SEQUENTIAL)
.build()
.kickoff();Real scenarios where agents put this tool to work.
Implementation lives at swarmai-tools/src/main/java/ai/intelliswarm/swarmai/tool/common/JSONTransformTool.java in the swarm-ai repository.