I have started using https://mholt.github.io/json-to-go/ to turn API JSON into go structs and I really like it, however I am stuck on how to initialize the Filters array struct in the Report Definition struct shown below.
type ReportDefinition struct {
ReportName string `json:"reportName"`
ReportType string `json:"reportType"`
Product string `json:"product"`
Email string `json:"email"`
CreatedBy string `json:"createdBy"`
Duration struct {
Duration string `json:"duration"`
StartDate interface{} `json:"startDate"`
EndDate interface{} `json:"endDate"`
} `json:"duration"`
Filters []struct {
Column struct {
ColumnName string `json:"columnName"`
Value string `json:"value"`
} `json:"column"`
Operator string `json:"operator"`
} `json:"filters"`
SortBy interface{} `json:"sortBy"`
ReportGroup interface{} `json:"reportGroup"`
ReportOnHierarchy bool `json:"reportOnHierarchy"`
IsReportPreview string `json:"isReportPreview"`
OutputRecordCount interface{} `json:"outputRecordCount"`
Schedule interface{} `json:"schedule"`
Columns []interface{} `json:"columns"`
}
I cannot seem to reference the items declared within the Filters struct or even the Filters struct in order to create a new Filter item and append it to Filters.
Is it possible to reference the Column struct with the ReportDefinition written as is? Or am I am doing something silly and I should just declare Filters outside of the ReportDefinition structure?