MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / ConvertJSONString

Function ConvertJSONString

base/util.go:188–196  ·  view source on GitHub ↗

Convert a JSON string, which has extra double quotes (eg, `"thing"`) into a normal string with the extra double quotes removed (eg "thing"). Normal strings will be returned as-is. `"thing"` -> "thing" "thing" -> "thing"

(s string)

Source from the content-addressed store, hash-verified

186// `"thing"` -> "thing"
187// "thing" -> "thing"
188func ConvertJSONString(s string) string {
189 var jsonString string
190 err := JSONUnmarshal([]byte(s), &jsonString)
191 if err != nil {
192 return s
193 } else {
194 return jsonString
195 }
196}
197
198// ConvertToJSONString takes a string, and returns a JSON string, with any illegal characters escaped.
199func ConvertToJSONString(s string) string {

Callers 5

getJSONStringQueryMethod · 0.92
ParseJSONSequenceIDFunction · 0.92
TestConvertJSONStringFunction · 0.85
TestJSONStringUtilsFunction · 0.85
BenchmarkJSONStringUtilsFunction · 0.85

Calls 1

JSONUnmarshalFunction · 0.70

Tested by 3

TestConvertJSONStringFunction · 0.68
TestJSONStringUtilsFunction · 0.68
BenchmarkJSONStringUtilsFunction · 0.68