feat: Add an AI-Proxy Wasm plugin (#921)

Co-authored-by: 澄潭 <zty98751@alibaba-inc.com>
This commit is contained in:
Kent Dong
2024-05-14 17:00:12 +08:00
committed by GitHub
parent 5c7736980c
commit 333f9b48f3
21 changed files with 2124 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
package util
import (
"strconv"
"strings"
)
func EscapeStringForJson(s string) string {
var builder strings.Builder
for _, c := range s { //iterate through rune
switch c {
case '"':
builder.WriteRune('\\')
builder.WriteRune(c)
break
default:
quoted := strconv.QuoteRune(c)
builder.WriteString(quoted[1 : len(quoted)-1])
}
}
return builder.String()
}