Skip to main content

Overview

JSON tool allows you to read, write, and query JSON files.

Installation

pip install "praisonai[tools]"

Quick Start

from praisonai_tools import JSONTool

# Initialize
json_tool = JSONTool()

# Read JSON
data = json_tool.read("config.json")
print(data)

Usage with Agent

from praisonaiagents import Agent
from praisonai_tools import JSONTool

agent = Agent(
    name="DataProcessor",
    instructions="You help process JSON data.",
    tools=[JSONTool()]
)

response = agent.chat("Read config.json and show the database settings")
print(response)

Available Methods

read(path)

Read a JSON file.
from praisonai_tools import JSONTool

json_tool = JSONTool()
data = json_tool.read("data.json")

write(path, data)

Write data to a JSON file.
json_tool.write("output.json", {"key": "value"})

query(path, jq_query)

Query JSON with JQ-like syntax.
result = json_tool.query("data.json", ".users[0].name")
  • CSV - CSV files
  • File - General files