golang[91]-复杂的json转换为结构体

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
type MultiTransData struct {
AccountDetailsMap map[string][]struct {
Account int
Stretegy int
}
}


to

{
"AccountDetailsMap":{
"GOLD:":[ {"Account":1,"Stretegy":2},{"Account":5,"Stretegy":6} ],
"WTI:":[{"Account":3,"Stretegy":4}]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
type BackTestRequest struct {
StrategyName string
Table string
Direction int32
Way int32
TradeNum int32
TP int32
SL int32
SLTPIndex int32
Capital float64
StartTime Time
EndTime Time
RequestId string
Callback string
SpreadMap map[string]Spread `json:"spread_list"`
}

type Spread struct {
OriginalSpread int32
StrategySpread int32
}

to

{
"StrategyName": "backtest_12",
"Table": "backtest_12",
"Direction": 1,
"Way": 2,
"TradeNum": 3,
"TP": 4,
"SL": 5,
"SLTPIndex": 6,
"Capital": 7,
"StartTime": "0001-01-01T00:00:00Z",
"EndTime": "0001-01-01T00:00:00Z",
"RequestId": "",
"Callback": "",
"spread_list":{
"GOLD:":{
"OriginalSpread":1,
"StrategySpread":2
},
"WTI:":{
"OriginalSpread":3,
"StrategySpread":4
}
}
}