0
我想從一個JSON對象中取出一個JSON對象,該對象中有一個JSON字符串,它本身是JSON,但它作爲字符串轉義。它看起來是這樣的:Unmarshal Escaped JSON字符串
{
"duration": "126.61ms",
"startTime": "2016-02-19T20:01:17.884Z",
"total": 123,
"content": [
{
"dateCreated": "2016-02-19T20:01:09.181Z",
"lastUpdated": "2016-02-19T20:01:09.181Z",
"name": "name",
"stats": "{\"id\":545,\"lastUpdated\":\"2015-01-09T19:16:04.535Z\",\"all\":{\"runs\":{\"count\":123}"
}
}
我試圖解組是爲這樣的結構:
type RunStatus struct {
Duration string `json:"duration"`
StartTime time.Time `json:"startTime"`
Total int `json:"total"`
Content []struct {
DateCreated time.Time `json:"dateCreated"`
LastUpdated time.Time `json:"lastUpdated"`
name string `json:"name"`
stats string `json:"stats"`
} `json:"content"`
}
什麼來獲得逃脫JSON對象到統計數據的最佳方式結構,而不是它在一個字符串?
我正在使用https://github.com/antonholmquist/jason。這是非常容易使用和理解和迭代。一探究竟。 – pregmatch