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{})
| 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 |
| 18 | func 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 |
| 34 | func ToString(data interface{}) string { |
nothing calls this directly
no test coverage detected