in internal/kernel/manage-object.go [47:91]
func appendExportedProperties(vt reflect.Type, overrides []api.Override, found map[string]bool) []api.Override {
if vt.Kind() == reflect.Ptr {
vt = vt.Elem()
}
if vt.Kind() == reflect.Struct {
for idx := 0; idx < vt.NumField(); idx++ {
field := vt.Field(idx)
// Unexported fields are not relevant here...
if !field.IsExported() {
continue
}
// Anonymous fields are embed, we traverse them for fields, too...
if field.Anonymous {
overrides = appendExportedProperties(field.Type, overrides, found)
continue
}
jsonName := field.Tag.Get("json")
if jsonName == "-" {
// Explicit omit via `json:"-"`
continue
} else if jsonName != "" {
// There could be attributes after the field name (e.g. `json:"foo,omitempty"`)
jsonName = strings.Split(jsonName, ",")[0]
}
// The default behavior is to use the field name as-is in JSON.
if jsonName == "" {
jsonName = field.Name
}
if !found[jsonName] {
overrides = append(overrides, &api.PropertyOverride{
JsiiProperty: jsonName,
// Using the "." prefix to signify this isn't actually a getter, just raw field access.
GoGetter: fmt.Sprintf(".%s", field.Name),
})
found[jsonName] = true
}
}
}
return overrides
}