我一直在为我的一个小项目编写此代码,我想解析一些看起来像这样的JSON数据:{ "payloads": [ { "xss": [ { "payload": "{{RANDSTR}}\"><scRiPT>alert(1)</ScrIPT>{{RANDSTR}}", "search": "{{RANDSTR}}\"><scRi" }, { "payload": "{{RANDSTR}}\"", "search": "{{RANDSTR}}\"" }, { "payload": "{{RANDSTR}}'", "search": "{{RANDSTR}}'" } ], "tpli": [ { "payload": "{{RANDSTR}}${{ {{RANDINT}} * {{RANDINT}} }}", "search": "{{RANDSTR}}{{RANDINT}}" }, { "payload": "{{RANDSTR}}{{ {{RANDINT}} * {{RANDINT}} }}", "search": "{{RANDSTR}}{{RANDINT}}" }, { "payload": "{{RANDSTR}}{! {{RANDINT}} * {{RANDINT}} !}", "search": "{{RANDSTR}}{{RANDINT}}" }, { "payload": "{{RANDSTR}}{% {{RANDINT}} * {{RANDINT}} %}", "search": "{{RANDSTR}}{{RANDINT}}" } ] } ]}这是我的结构声明:type Payload struct { Payload []struct { Payload string `json:"payload"` Search string `json:"search"` }}type Payloads struct { Payloads []Payload `json:"payloads"`}我知道这不是我应该做的事情,但我不确定最好的方法。我不想指定键(xss,tpli等),因为我想轻松扩展此文件而无需修改Go文件。有人能为我指出如何实现这一目标的正确方向吗?
1 回答
宝慕林4294392
TA贡献2021条经验 获得超8个赞
将其建模为:
type Payloads struct {
Payloads []map[string][]Payload `json:"payloads"`
}
type Payload struct {
Payload string `json:"payload"`
Search string `json:"search"`
}
游乐场: https://play.golang.org/p/S6nnOKkADUO
- 1 回答
- 0 关注
- 92 浏览
添加回答
举报
0/150
提交
取消