MCPcopy
hub / github.com/SleepingBag945/dddd / JSONScalarToString

Function JSONScalarToString

lib/nuclei/pkg/types/interfaces.go:18–31  ·  view source on GitHub ↗

JSONScalarToString converts an interface coming from json to string Inspired from: https://github.com/cli/cli/blob/09b09810dd812e3ede54b59ad9d6912b946ac6c5/pkg/export/template.go#L72

(input interface{})

Source from the content-addressed store, hash-verified

16// JSONScalarToString converts an interface coming from json to string
17// Inspired from: https://github.com/cli/cli/blob/09b09810dd812e3ede54b59ad9d6912b946ac6c5/pkg/export/template.go#L72
18func JSONScalarToString(input interface{}) (string, error) {
19 switch tt := input.(type) {
20 case string:
21 return ToString(tt), nil
22 case float64:
23 return ToString(tt), nil
24 case nil:
25 return ToString(tt), nil
26 case bool:
27 return ToString(tt), nil
28 default:
29 return "", fmt.Errorf("cannot convert type to string: %v", tt)
30 }
31}
32
33// ToString converts an interface to string in a quick way
34func ToString(data interface{}) string {

Callers

nothing calls this directly

Calls 1

ToStringFunction · 0.70

Tested by

no test coverage detected