feat: add百炼
This commit is contained in:
12
src/utils/json.ts
Normal file
12
src/utils/json.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* 尝试从字符串中提取JSON对象
|
||||
*/
|
||||
export const getJsonFromString = (str: string) => {
|
||||
try {
|
||||
const jsonMatch = str.match(/```json\s*([\s\S]*?)\s*```/);
|
||||
if (jsonMatch && jsonMatch[1]) {
|
||||
return JSON.parse(jsonMatch[1]);
|
||||
}
|
||||
} catch (error) {}
|
||||
return null;
|
||||
};
|
||||
Reference in New Issue
Block a user