初始化-第一次提交

This commit is contained in:
Zihaoxu2008
2025-01-24 22:33:29 +08:00
commit 790e1f7fd0
6 changed files with 1988 additions and 0 deletions

37
src/utils.rs Normal file
View File

@@ -0,0 +1,37 @@
// 处理json组件
pub fn parse_json_component(json: &str) -> String {
let data: serde_json::Value = serde_json::from_str(json).unwrap();
let mut res: String = String::new();
let text = data.get("text");
match text {
Some(t) => {
if t.is_string(){
res += t.as_str().unwrap();
}
}
None => {
let translate = data.get("translate");
match translate {
Some(t) => {
if t.is_string(){
res += t.as_str().unwrap();
}
}
None => {}
}
}
}
let extra = data.get("extra");
match extra {
Some(t) =>{
for i in t.as_array().unwrap(){
if !i.is_object(){
continue;
}
res += parse_json_component(i.to_string().as_str()).as_str();
}
}
None => {}
}
return res;
}