Я хочу создать эту политику JSON:
{"Statement":[{"Resource":"RESOURCE","Condition":{"DateLessThan":{"AWS:EpochTime":EXPIRES}}}]}
Решение, которое я показываю ниже, дает следующий JSON:
{"Statement":{"Resource":"example.com","Condition":{"DateLessThan":{"AWS:EpochTime":"1234543"}}}}
Как мне изменить это так, чтобы "Statement": имел значение массива?
package main
import (
"json"
"fmt"
)
type S struct {
Statement Statement
}
type Statement struct {
Resource string
Condition Date
}
type Date struct {
DateLessThan AWS
}
type AWS struct {
EpochTime string "AWS:EpochTime"
}
func main() {
expires := "1234543"
resource := "example.com"
date := &AWS{EpochTime: expires}
date2 := &Date{DateLessThan:*date}
reso := &Statement{Resource: resource, Condition: *date2}
statement := &S{Statement: *reso}
result1, _ := json.Marshal(statement)
fmt.Printf(result1)
}