Files
StackChan/app/lib/model/XiaoZhi/common_mcp_tool.dart

49 lines
1.4 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
SPDX-License-Identifier: MIT
*/
class CommonMcpTool {
String? endpoint_id;
String? name;
String? language;
//Constructorfunction
CommonMcpTool({this.endpoint_id, this.name, this.language});
//1. singleobjectfrom JSON Deserialize
factory CommonMcpTool.fromJson(Map<String, dynamic> json) {
return CommonMcpTool(
endpoint_id: json['endpoint_id'] as String?,
name: json['name'] as String?,
language: json['language'] as String?,
);
}
//2. singleobjectSerializeas JSON
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['endpoint_id'] = endpoint_id;
data['name'] = name;
data['language'] = language;
return data;
}
//3. JSON arrayconvertas CommonMcpTool list(core FromListJson Implement)
static List<CommonMcpTool> fromListJson(List<dynamic> jsonList) {
//iterate JSON arrayone by oneconvertas CommonMcpTool object
return jsonList
.map(
(jsonItem) =>
CommonMcpTool.fromJson(jsonItem as Map<String, dynamic>),
)
.toList();
}
//optionalExtension:CommonMcpTool listconvertas JSON array
static List<Map<String, dynamic>> toListJson(List<CommonMcpTool>? toolList) {
if (toolList == null) return [];
return toolList.map((tool) => tool.toJson()).toList();
}
}