MCPcopy Create free account
hub / github.com/IBM/newrelic-cli / ToJSON

Function ToJSON

utils/decoder.go:35–40  ·  view source on GitHub ↗

ToJSON converts a single YAML document into a JSON document or returns an error. If the document appears to be JSON the YAML decoding path is not used (so that error messages are JSON specific).

(data []byte)

Source from the content-addressed store, hash-verified

33// YAML decoding path is not used (so that error messages are
34// JSON specific).
35func ToJSON(data []byte) ([]byte, error) {
36 if hasJSONPrefix(data) {
37 return data, nil
38 }
39 return yaml.YAMLToJSON(data)
40}
41
42// YAMLToJSONDecoder decodes YAML documents from an io.Reader by
43// separating individual documents. It first converts the YAML

Callers

nothing calls this directly

Calls 1

hasJSONPrefixFunction · 0.85

Tested by

no test coverage detected