mirror of
https://github.com/alibaba/higress.git
synced 2026-05-31 08:07:26 +08:00
feat: Add an AI-Proxy Wasm plugin (#921)
Co-authored-by: 澄潭 <zty98751@alibaba-inc.com>
This commit is contained in:
22
plugins/wasm-go/extensions/ai-proxy/util/json.go
Normal file
22
plugins/wasm-go/extensions/ai-proxy/util/json.go
Normal 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()
|
||||
}
|
||||
Reference in New Issue
Block a user