MCPcopy Create free account
hub / github.com/cli/cli / UnmarshalJSON

Method UnmarshalJSON

pkg/iostreams/untrusted.go:63–70  ·  view source on GitHub ↗

UnmarshalJSON lets a struct field typed as Untrusted be populated directly by json.Unmarshal, so provenance is preserved across a JSON decode. This is what lets a decoded field (e.g. a streamed log line) stay labeled when the surrounding response was never sanitized by the JSON transport.

(data []byte)

Source from the content-addressed store, hash-verified

61// lets a decoded field (e.g. a streamed log line) stay labeled when
62// the surrounding response was never sanitized by the JSON transport.
63func (u *Untrusted) UnmarshalJSON(data []byte) error {
64 var s string
65 if err := json.Unmarshal(data, &s); err != nil {
66 return err
67 }
68 u.raw = s
69 return nil
70}
71
72// MarshalJSON emits the raw content as a JSON string so a value round-trips
73// faithfully through encode/decode.

Callers 3

SigstoreBundleFunction · 0.80
GitHubReleaseBundleFunction · 0.80
GetAttestationsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected