0
我想生成這個JSON政策:代表圍棋JSON政策
{"Statement":[{"Resource":"RESOURCE","Condition":{"DateLessThan":{"AWS:EpochTime":EXPIRES}}}]}
我展示以下解決方案將產生以下JSON:
{"Statement":{"Resource":"example.com","Condition":{"DateLessThan":{"AWS:EpochTime":"1234543"}}}}
如何改變這種做法, 「聲明」:有一個數組值?
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)
}