mirror of https://github.com/tidwall/tile38.git
14 lines
219 B
Go
14 lines
219 B
Go
|
package controller
|
||
|
|
||
|
import "encoding/json"
|
||
|
|
||
|
func jsonString(s string) string {
|
||
|
for i := 0; i < len(s); i++ {
|
||
|
if s[i] < 32 || s[i] > 126 {
|
||
|
d, _ := json.Marshal(s)
|
||
|
return string(d)
|
||
|
}
|
||
|
}
|
||
|
return `"` + s + `"`
|
||
|
}
|