MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / parseJSONStringList

Function parseJSONStringList

internal/store/oauth.go:948–961  ·  view source on GitHub ↗

parseJSONStringList decodes a JSON array string back to []string. Empty / null inputs produce an empty (non-nil) slice so callers can range without nil-checking.

(raw string)

Source from the content-addressed store, hash-verified

946// Empty / null inputs produce an empty (non-nil) slice so callers
947// can range without nil-checking.
948func parseJSONStringList(raw string) ([]string, error) {
949 raw = strings.TrimSpace(raw)
950 if raw == "" || raw == "null" {
951 return []string{}, nil
952 }
953 var out []string
954 if err := json.Unmarshal([]byte(raw), &out); err != nil {
955 return nil, err
956 }
957 if out == nil {
958 out = []string{}
959 }
960 return out, nil
961}
962
963// cloneStringSlice returns a copy of in so callers holding the
964// returned model can't mutate the input the caller still owns.

Callers 1

GetOAuthClientMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected