MCPcopy
hub / github.com/cli/cli / ExportData

Method ExportData

pkg/search/result.go:360–379  ·  view source on GitHub ↗
(fields []string)

Source from the content-addressed store, hash-verified

358}
359
360func (repo Repository) ExportData(fields []string) map[string]interface{} {
361 v := reflect.ValueOf(repo)
362 data := map[string]interface{}{}
363 for _, f := range fields {
364 switch f {
365 case "license":
366 data[f] = map[string]interface{}{
367 "key": repo.License.Key,
368 "name": repo.License.Name,
369 "url": repo.License.URL,
370 }
371 case "owner":
372 data[f] = repo.Owner.ExportData()
373 default:
374 sf := fieldByName(v, f)
375 data[f] = sf.Interface()
376 }
377 }
378 return data
379}
380
381func (repo Repository) MarshalJSON() ([]byte, error) {
382 return json.Marshal(map[string]interface{}{

Callers

nothing calls this directly

Calls 2

fieldByNameFunction · 0.70
ExportDataMethod · 0.65

Tested by

no test coverage detected