初始提交

This commit is contained in:
2026-08-26 18:06:02 +08:00
commit 5544788917
53 changed files with 4101 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
namespace MAF1.Utils;
public static class JsonText
{
public static string UnwrapObject(string text)
{
string trimmed = text.Trim();
if (trimmed.StartsWith("```", StringComparison.Ordinal))
{
int firstNewLine = trimmed.IndexOf('\n');
int lastFence = trimmed.LastIndexOf("```", StringComparison.Ordinal);
if (firstNewLine >= 0 && lastFence > firstNewLine)
{
trimmed = trimmed[(firstNewLine + 1)..lastFence].Trim();
}
}
int objectStart = trimmed.IndexOf('{');
int objectEnd = trimmed.LastIndexOf('}');
if (objectStart >= 0 && objectEnd > objectStart)
{
return trimmed[objectStart..(objectEnd + 1)];
}
return trimmed;
}
}