MCPcopy
hub / github.com/dgraph-io/dgraph / escapedString

Function escapedString

worker/export.go:118–129  ·  view source on GitHub ↗

escapedString converts a string into an escaped string for exports.

(str string)

Source from the content-addressed store, hash-verified

116
117// escapedString converts a string into an escaped string for exports.
118func escapedString(str string) string {
119 // We use the Marshal function in the JSON package for all export formats
120 // because it properly escapes strings.
121 byt, err := json.Marshal(str)
122 if err != nil {
123 // All valid stings should be able to be escaped to a JSON string so
124 // it's safe to panic here. Marshal has to return an error because it
125 // accepts an interface.
126 x.Panic(errors.New("Could not marshal string to JSON string"))
127 }
128 return string(byt)
129}
130
131func (e *exporter) toJSON() (*bpb.KVList, error) {
132 bp := new(bytes.Buffer)

Callers 2

toJSONMethod · 0.85
toRDFMethod · 0.85

Calls 1

PanicFunction · 0.92

Tested by

no test coverage detected