Package com.tnsai.roles.export
Class JsonRoleExporter
java.lang.Object
com.tnsai.roles.export.JsonRoleExporter
- All Implemented Interfaces:
RoleExporter
Exports Role definitions to JSON format.
Produces a clean JSON representation suitable for:
- API responses
- Configuration files
- Role sharing and import
- Documentation generation
Example Output
{
"name": "Researcher",
"goal": "Find and analyze information",
"domain": "Research",
"version": "1.0.0",
"responsibilities": {
"duties": ["Search databases", "Analyze papers"],
"mustNever": ["Fabricate data"],
"mustAlways": ["Cite sources"]
},
"llm": {
"provider": "openai",
"model": "gpt-4o",
"temperature": 0.7
},
"actions": [...]
}
- Author:
- TnsAI Team
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a JsonRoleExporter with pretty printing.JsonRoleExporter(boolean prettyPrint, int indentSpaces) Creates a JsonRoleExporter with custom formatting. -
Method Summary
Modifier and TypeMethodDescriptionexport(ExportedRole metadata) Exports role metadata to the target format.Exports a Role instance to the target format.exportFromClass(Class<? extends Role> roleClass) Exports a Role class (using annotations) to the target format.Returns the file extension for this export format.Returns the format name.Returns the MIME type for this export format.
-
Constructor Details
-
JsonRoleExporter
public JsonRoleExporter()Creates a JsonRoleExporter with pretty printing. -
JsonRoleExporter
public JsonRoleExporter(boolean prettyPrint, int indentSpaces) Creates a JsonRoleExporter with custom formatting.- Parameters:
prettyPrint- whether to format outputindentSpaces- spaces per indent level
-
-
Method Details
-
export
Description copied from interface:RoleExporterExports a Role instance to the target format.- Specified by:
exportin interfaceRoleExporter- Parameters:
role- the role to export- Returns:
- exported string representation
-
exportFromClass
Description copied from interface:RoleExporterExports a Role class (using annotations) to the target format.- Specified by:
exportFromClassin interfaceRoleExporter- Parameters:
roleClass- the role class with annotations- Returns:
- exported string representation
-
export
Description copied from interface:RoleExporterExports role metadata to the target format.- Specified by:
exportin interfaceRoleExporter- Parameters:
metadata- the extracted role metadata- Returns:
- exported string representation
-
getFileExtension
Description copied from interface:RoleExporterReturns the file extension for this export format.- Specified by:
getFileExtensionin interfaceRoleExporter- Returns:
- file extension (e.g., "json", "yaml", "asl")
-
getMimeType
Description copied from interface:RoleExporterReturns the MIME type for this export format.- Specified by:
getMimeTypein interfaceRoleExporter- Returns:
- MIME type
-
getFormatName
Description copied from interface:RoleExporterReturns the format name.- Specified by:
getFormatNamein interfaceRoleExporter- Returns:
- format name (e.g., "JSON", "YAML", "AgentSpeak")
-