Logo
Explore Help
Register Sign In
rms/VictoriaMetrics
1
0
Fork 0
You've already forked VictoriaMetrics
mirror of https://github.com/VictoriaMetrics/VictoriaMetrics.git synced 2026-06-29 05:25:26 +03:00
Code Issues Packages Projects Releases Wiki Activity
Files
eacd3c11ff7b3ffc69994dea4be6c0696119fd99
VictoriaMetrics/lib/stringsutil/json.go

11 lines
204 B
Go
Raw Normal View History

all: consistently use stringsutil.JSONString() for formatting JSON strings with fmt.* functions instead of using "%q" formatter The %q formatter may result in incorrectly formatted JSON string if the original string contains special chars such as \x1b . They must be encoded as \u001b , otherwise the resulting JSON string cannot be parsed by JSON parsers. This is a follow-up for c0caa6993903a748c8942c8c28b5901ee6d5f4d4 See https://github.com/VictoriaMetrics/victorialogs-datasource/issues/24
2024-07-17 13:52:10 +02:00
package stringsutil
import (
"github.com/valyala/quicktemplate"
)
// JSONString returns JSON-quoted s.
func JSONString(s string) string {
return string(quicktemplate.AppendJSONString(nil, s, true))
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.25.5 Page: 691ms Template: 3ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API