Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://go.dev/play/p/khG7qBROaIx
- package main
- import (
- "encoding/json"
- "fmt"
- )
- func main() {
- fmt.Println(jsonEscape(`dog "fish" cat`))
- }
- func jsonEscape(i string) string {
- b, err := json.Marshal(i)
- if err != nil {
- panic(err)
- }
- s := string(b)
- return s[1 : len(s)-1]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement